Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-09-2011, 11:00 PM   #4 (permalink)
NMF
Registered Member
 
Join Date: Feb 2011
Location: Colorado
Posts: 1
NMF is on a distinguished road
Question 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.
NMF is offline   Reply With Quote
 

» Advertisements
» Online Users: 390
9 members and 381 guests
7twenty7, antonwilliams, Arty Tales, DaveDee, erdinc27, Lily.P, MarkC, roof44, ryantcb
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,594
Threads: 94,083
Posts: 402,778
Top Poster: BrianSlick (7,990)
Welcome to our newest member, kopmlop
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.