i need to define an array as global variable that i can use it all over my code the array must have a data for 10 random number that must be fixed all over the code what i did it the following but with no luck
in the .h file after the @interface i put this line
NSMutableArray *globalarray;
and in the .m file i put this after the @implemention file
- (void)glo {
if (!globalarray) {
globalarray= [NSMutableArray globalarray];
for (int x = 0; x < 10; x++) {
[globalarray addObject:[NSNumber numberWithInt: arc4random()%200]];
}}}
and on the same .m file i called the array in NSLOG as follows
-(IBAction)click_one:(id)sender{
NSLog(@"%@",globalarray);}
-(IBAction)click_two:(id)sender{
NSLog(@"%@",globalarray);}
the NSLOG returns null in the console any help is highly apprectaied thanks
This line:
assumes that there’s some method on NSMutableArray called “globalarray”. There isn’t. You want: