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

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

Draw This
($0.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-01-2009, 02:00 PM   #1 (permalink)
starwarsdevwookie59
Registered Member
 
Join Date: Mar 2009
Posts: 157
starwarsdevwookie59 is on a distinguished road
Default Mutable Array to NSUserDefaults?!?

So I have some code that save an array in the appwillterminate section and then in the appdidload it pulls it back in. It works great for editing the one item in the array, however, as soon as you start to add objects to the array it crashes. I read something about needed to save a mutable array as a specific "mutable copy" and then it would allow you to add and delete it. My app really depends on me being able to save the state of my nsmutable arrays and then retrieve it. Im having much dificulty doing so though. Has any one gotten this to work? Heres my code:

- (void)applicationDidFinishLaunchingUIApplication *)application {
projectsArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"projectsArray"];
if (projectsArray == NULL) {
projectsArray = [[NSMutableArray arrayWithObjects:@"New Project", nil] retain];
}
}

- (void)applicationWillTerminateUIApplication *)application {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObjectrojectsArray forKey:@"projectsArray"];
// Save data if appropriate
}

Any help would be sweet thanks!!!
starwarsdevwookie59 is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,017
Threads: 93,863
Posts: 401,918
Top Poster: BrianSlick (7,962)
Welcome to our newest member, marce43b
Powered by vBadvanced CMPS v3.1.0

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