• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Not sure what's wrong with this code to using NSUserDefaults...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not sure what's wrong with this code to using NSUserDefaults...


  • Subject: Re: Not sure what's wrong with this code to using NSUserDefaults...
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 24 Jun 2010 14:40:19 -0700

On Jun 23, 2010, at 5:11 PM, Patrick William Walker wrote:

> NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
>
> [prefs setObject: @"120" forKey: @"Length"];
>
> [prefs synchronize];
>
>
> When the program is run in the iPhone simulator (v3.2, not using 4.0 yet), it just dies.  Nothing on the console log so I set a breakpoint and got a backtrace.  It's pointing to the setObject: method call and it's generating an access exception.  If I comment out the setObject portion, it runs fine.

My only guess is that you have some other code elsewhere in the app that’s incorrectly calling -release on the shared NSUserDefaults instance, causing it to be dealloced, so the next access to that object will crash. Take a careful look at the other places in your code that use NSUserDefaults.

—Jens

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Not sure what's wrong with this code to using NSUserDefaults...
      • From: Greg Parker <email@hidden>
References: 
 >Not sure what's wrong with this code to using NSUserDefaults... (From: Patrick William Walker <email@hidden>)

  • Prev by Date: Re: Best way to determine if a directory is a package
  • Next by Date: Re: Not sure what's wrong with this code to using NSUserDefaults...
  • Previous by thread: Not sure what's wrong with this code to using NSUserDefaults...
  • Next by thread: Re: Not sure what's wrong with this code to using NSUserDefaults...
  • Index(es):
    • Date
    • Thread