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 6156273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:34:52+00:00 2026-05-23T20:34:52+00:00

How do I build up a global like integer array? I tried variations of

  • 0

How do I build up a global like integer array?

I tried variations of the following:

@interface
int *iArray; //this space will vary depending upon need in the implementation

@implementation
...
int iArrayInit[4] = {1,2,3,4};
iArray = iArrayInit;

-bottom line: I need to keep index values in array that I can access easily, and use of [NSArray intValue] maybe to slow.

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-23T20:34:54+00:00Added an answer on May 23, 2026 at 8:34 pm

    If it needs to be static you can declare an NSMutableArray as static in the implementation file and expose static methods to access it. When using an NSArray the values need to be of type id which NSNumber can do. Here is an example which currently is not thread safe.

    //.h file
    @interface Foo : NSObject
    {   
    }
    
    +(NSArray*)iArray;
    +(void)addiArrayValue:(NSNumber*)value;
    
    @end
    
    //.m file
    @implementation Foo
    
    static NSMutableArray *_iArray;
    
    +(void)initialize
    {
        if([Foo class] == self)
        {
            _iArray = [[NSMutableArray alloc] init];
        }
    }
    
    +(NSArray*)iArray
    {
        return [[_iArray copy] autorelease];
    }
    
    +(void)addiArrayValue:(NSNumber*)value
    {
        [_iArray addObject:value];
    }
    
    @end
    
    //Use
    [Foo addiArrayValue:[NSNumber numberWithInt:10]];
    [Foo addiArrayValue:[NSNumber numberWithInt:12]];
    NSLog(@"%@", [Foo iArray]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following problem: I would like to build a little clipboard with jQuery. I have
I'm trying to run this script: import re, os def build_pool(cwd): global xtn_pool, file_pool
I'm attempting to build a way for my selectors to 'listen' to 'global' events
I build up an array of strings with string[] parts = string.spilt( ); And
I would like to avoid having to build a menu manually in XAML or
I'm converting a build that has 71 .jar files in its global lib/ directory
This is what I would like: I want to keep the Silverlight default menu
I would like to build a simulation engine which can simulate a soccer (association
I'm trying to build a global menu into my ASP.NET MVC site.master, and I
I would like to set a specific cookie domain for my cookies, because this

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.