Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-10-2009, 07:48 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Clinton Twp, MI
Posts: 106
Default nsuserdefaults favorites problem

i have an app that generates different questions. i have a tab bar at the bottom that lets users view "recents" and also "favorites." i'm using nsuserdefaults to save the array of favorites/recents into a table.

for some reason i can never add to favorites/recents on the initial installs of the appilcation. it only works once I have opened my recents/favorites and then exit and re-launch the program. b/c of that i think it may be related to something within my "viewWillAppear" but i'm not totally sure.

Code:
- (void)viewWillAppear:(BOOL)animated {
	[super viewWillAppear:animated];
	MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
	self.myFavorites = [NSMutableArray arrayWithArray:appDelegate.favoriteQuestions1];
	self.myFavorites2 = [NSMutableArray arrayWithArray:appDelegate.favoriteQuestions2];
	self.myCategories = [NSMutableArray arrayWithArray:appDelegate.favoriteTypes];
	self.myVerses = [NSMutableArray arrayWithArray:appDelegate.favoriteVerses];
	
	
	NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
	// saving the array
	
	[prefs setObject:myFavorites forKey:@"favorites1"];
	[prefs setObject:myFavorites2 forKey:@"favorites2"];
	[prefs setObject:myCategories forKey:@"favoriteTypes"];
	[prefs setObject:myVerses forKey:@"favoriteVerses"];
	[prefs synchronize];
	[self.tableView reloadData];	
}
does this look like it could be the cause of my problem? if not, where should I look?
__________________
Check out one of my Apps!
BlackOut, or PhraseCraze

Or check me out online at GrunewaldDev.com or Follow me on Twitter
rjgrune is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,769
Threads: 38,538
Posts: 169,283
Top Poster: smasher (2,544)
Welcome to our newest member, DragonFlyJones
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0