I want a NSMutableArray global. I have the following setup:
code.h
extern NSMutableArray *global
@interface
@end
code.m
NSMutableArray *global=nil;
@implementation
...
global=variable_mutablearray; //copy variable_mutablearray to global
@end
I’m pretty sure that what I’m doing setting an existing nsmutablearray to the global variable is not correct. What should I be doing?
Globals are not the best thing to use in Objective C: it is much better to use a singleton.
You can do it like this:
Header:
Implementation:
Usage: