Global NSArray
Hey Robert,
Thanks for taking the time to write out this post it was helpful for me to understand how objective C works. I used your method explained in the post to try and create a global NSArray that I could share across views.
//In my first view in the "viewDidLoad" method I do
AppDelegate *appDel = [[UIApplication sharedApplication] delegate];
//I then set my array with 14 strings
appDel.delArray = viewArray;
//I then ensure the array has something in it
NSLog(@"Count: %d", [appDel.test count]);
//which returns 14
//I then go to my second view in the "viewDidLoad" method I do
AppDelegate *appDel = [[UIApplication sharedApplication] delegate];
//At this point I expect that my array should have 14 strings in it
NSLog(@"Count: %d", [appDel.test count]);
//But the above line returns 0 and I am not sure where I am going wrong
I did the same process with an NSString just to see what would happen. I set it in one view and get it in the second and it works with no problems. Can you provide advice on creating a global NSArray or NSMutableArray (is what I really want) across multiple views? I also tried doing it using a singleton class with no luck, once again other objects worked just not array objects. Thanks in advance for any help you can provide.
|