I have a Singleton and I'd like to declare an NSArray, but I'd like to init it with 5 (non -consecutive) integers.
Right now it's declared in the .h>Interface, .h>@property, and .m>@synthesize.
How can I do this? Thanks.
I have a Singleton and I'd like to declare an NSArray, but I'd like to init it with 5 (non -consecutive) integers.
Right now it's declared in the .h>Interface, .h>@property, and .m>@synthesize.
How can I do this? Thanks.
In your singleton's -init method, simply create and initialize it there:
- (id)init
{
_array = [[NSArray arrayWithObjects:[NSNumber numberWithInt:5], [NSNumber numberWithInt:50], [NSNumber numberWithInt:3.72], [NSNumber numberWithInt:5], [NSNumber numberWithInt:96], nil] retain];
return self;
}