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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 07-24-2009, 11:58 AM   #1 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
Default Manually Edit NSUserDefaults

Is it possible to view the values stored in NSUserDefaults standardUserDefaults without running the simulator? it would be nice to edit/clear/view them for debugging purposes.
red is offline   Reply With Quote
Old 07-24-2009, 12:13 PM   #2 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
Default

I may have found a bug in the simulator. NSUserDefaults cannot remove a key from memory permanently. I have this code:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_IDENTIFIER];
...
}
// Function that gets called later in the code
NSMutableArray *temp = [[NSUserDefaults standardUserDefaults] objectForKey:KEY_IDENTIFIER];
NSLog(@"  Delegate: Array = %@", temp);
When I run this code, it will display temp = nil (as expected). Then, I close the simulator and uncomment the line of code that removes the object from NSUserDefaults and I build the code again. The value of temp is not nil. It equals the values that were stored in [[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_IDENTIFIER] from a previous time.

Is this a bug, or am i missing something huge?
red is offline   Reply With Quote
Old 07-24-2009, 12:39 PM   #3 (permalink)
Shmoopi LLC
 
Shmoopi's Avatar
 
Join Date: Jun 2009
Location: Virginia
Posts: 203
Default

Quote:
Originally Posted by red View Post
I may have found a bug in the simulator. NSUserDefaults cannot remove a key from memory permanently. I have this code:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_IDENTIFIER];
...
}
// Function that gets called later in the code
NSMutableArray *temp = [[NSUserDefaults standardUserDefaults] objectForKey:KEY_IDENTIFIER];
NSLog(@"  Delegate: Array = %@", temp);
When I run this code, it will display temp = nil (as expected). Then, I close the simulator and uncomment the line of code that removes the object from NSUserDefaults and I build the code again. The value of temp is not nil. It equals the values that were stored in [[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_IDENTIFIER] from a previous time.

Is this a bug, or am i missing something huge?
Try resetting all contents and settings in the simulator and see what happens
Shmoopi is offline   Reply With Quote
Old 07-24-2009, 01:31 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

<username> -> Library -> Application Support -> iPhone Simulator -> User -> Applications -> <figure out which folder is for app you're interested in, if more than one> -> Library -> Preferences -> com.yourname.yourappname.plist

I have the Applications folder stored as a Favorite so I can quickly get back to it. I don't know if the goofy alpha-numeric folder names stay the same for each app build, especially if you remove them, so I'm not sure how reliable a link to the specific folder would be. I'll set the view to be date-sorted, and the first item should be my most recently built app.


The problem you might be seeing is that you cannot pull -mutable- data (see docs) out of a plist. Trying reading it into an NSArray instead, see if that helps.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:

Last edited by BrianSlick; 07-24-2009 at 01:34 PM.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
nsuserdefaults

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: 261
16 members and 245 guests
@sandris, ADY, dacapo, Dani77, djohnson, HemiMG, JasonR, MarkC, mer10, nibeck, prchn4christ, ryandb2, spiderguy84, timle8n1, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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