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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-06-2009, 08:27 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 36
MacBuddy is on a distinguished road
Exclamation HELP!! PLEASE

NSString *filePath = [[NSBundle mainBundle]pathForResource:@"ScoreBoard" ofType:@"plist"];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
//Hmm

//@end Hmm
[plistDict setObject:[NSNumber numberWithBool:YES] forKey:@"enableScore"];
/* Backup
[plistDict setValue:@"YES" forKey:@"enableScore"]; */
[plistDict writeToFile:filePath atomically: NO];

I am trying to add this key into a dictionary that is already defined in the plist the Dictionary is called enabled and I want to add enableScore YES. This key is not in there so I have this set up to add the key, how do I tell it to add it to the dictionary?

Help asap please
MacBuddy is offline   Reply With Quote
Old 10-06-2009, 09:27 AM   #2 (permalink)
iPhone Developer
 
kohjingyu's Avatar
 
Join Date: May 2009
Location: Singapore
Posts: 326
kohjingyu is on a distinguished road
Default

I don't think you can save boolean variables to a plist. If I'm right, the only values you can save to a plist are an array, dictionary and string. And data, I think.

You might want to use NSUserDefaults.

Look at this: Saving data Chris-Software.com # iPhone & iPod Touch games and apps
__________________
Bacteria Bash
Cheese Collect
Jokestar
Follow me on Twitter for news about my apps:
(Website|Twitter)
kohjingyu is offline   Reply With Quote
Old 10-06-2009, 10:21 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 36
MacBuddy is on a distinguished road
Default

Quote:
Originally Posted by kohjingyu View Post
I don't think you can save boolean variables to a plist. If I'm right, the only values you can save to a plist are an array, dictionary and string. And data, I think.

You might want to use NSUserDefaults.

Look at this: Saving data Chris-Software.com # iPhone & iPod Touch games and apps
You can add booleans by the way.

Thanks for the link. That should help.
MacBuddy is offline   Reply With Quote
Old 10-07-2009, 08:42 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 36
MacBuddy is on a distinguished road
Default Use this but write it into a dictionary in a plist

Code:
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"ScoreBoard" ofType:@"plist"];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];

[plistDict setObject:[NSNumber numberWithBool:YES] forKey:@"enableScore"];
/* Backup
[plistDict setValue:@"YES" forKey:@"enableScore"]; */
[plistDict writeToFile:filePath atomically: NO];
I am using this but i want to be able to take
Code:
[plistDict setObject:[NSNumber numberWithBool:YES] forKey:@"enableScore"];
and write it into a dictionary that is already located in the plist.

Please Help
MacBuddy is offline   Reply With Quote
Reply

Bookmarks

Tags
dictionary, iphone, plist

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



» Advertisements
» Online Users: 346
10 members and 336 guests
givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mtl_tech_guy, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:34 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0