At the top of my .m file I have
static NSMutableArray *name;
I load a bunch of values into my *name array inside my viewDidLoad method.
I have a slider that can modify the values inside this array. The slider method is only called when the value of the slider changes. However, I ran this code and every time my program exits the viewDidLoad method I lose the values that were added to the global variable name. I can see that they were there before exiting the viewDidLoad method.
What am I doing wrong?
EDIT: Inside viewDidLoad
if (name == nil)
name = [NSMutableArray array];
UITextField *nameTemp = [[UITextField alloc] initWithFrame:CGRectMake(20,20,20,20)];
nameTemp.returnKeyType = UIReturnKeyDone;
etc
[self.view addSubview: nameTemp];
[name addObject:nameTemp]
[nameTemp release];
[NSMutableArray array]creates an autoreleased array that apparently is being released at the end of yourviewDidLoadmethod. Try using[[NSMutableArray alloc] init]or[[NSMutableArray array] retain]and see if the values persist afterviewDidLoadreturns.