Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4127076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:07:00+00:00 2026-05-21T00:07:00+00:00

I have a large constant (an NSString with 10^6 values). Because of its size

  • 0

I have a large constant (an NSString with 10^6 values). Because of its size I would like to declare it at the end of the source file (so I don’t have to scroll through it every time I want to edit my code). Also because of its size I would like it to be a constant so I can load it at compile time instead of runtime. Also, because I do not want it accessible to outside users I do not want to declare it as extern in the header file.

I have it declared as a constant using the code below in the implementation file, however it is giving me a “Use of undeclared identifier ‘hugeConstantString'” if I move it past the @end of the implementation (for obvious reasons).

NSString *const hugeConstantString = @"a_whooooooole_lotta_characters";

I’ve checked this out: Constants in Objective-C but it didn’t tell me anything I didn’t know already. Maybe my brain is fried, but: is there any way that I can define this huge constant AFTER my implementation and still have it accessible? Or if I declare it in another header file and import it, will it then be accessible to others?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T00:07:01+00:00Added an answer on May 21, 2026 at 12:07 am

    I am going to save the conversation of Why are you doing that and just post a simple solution for you. Thanks to Tommy in the comments here is a simpler version.

    #import "LargeStringTest.h"
    
    
    @implementation LargeStringTest
    
    //Declare the string
    static NSString *hugeConstantString;
    
    - (id)init {
        self = [super init];
        if (self) {
            NSLog(@"Large String %@", hugeConstantString);
        }
        return self;
    }
    
    //Place all other code here
    
    //Assign the string
    static NSString *hugeConstantString = @"a_whooooooole_lotta_characters";
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have large images displayed in a grouped tableview. I would like the images
I have a large constant html string which I'd like to display on my
I have a function which is constant to its argument, for example let is_prime
I doubt this is possible but what I would like to do is have
Once again, I have a problem for which I would like to shave off
I'd like to read a large XML file that contains over a million small
I have a (large) horizontally scrolling view, and a bunch of rectangles I'd like
I have a large number of lists (35 MB in total) which I would
I have large data sets (10 Hz data, so 864k points per 24 Hours)
I have large batches of XHTML files that are manually updated. During the review

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.