• 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: NSArrayController with User Defaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController with User Defaults


  • Subject: Re: NSArrayController with User Defaults
  • From: Nick Zitzmann <email@hidden>
  • Date: Fri, 16 Apr 2004 07:37:05 -0600

On Apr 16, 2004, at 3:38 AM, Johan Kool wrote:

In the same simple app I am trying to get the content of a NSArrayController saved into the user defaults. This seems to work when I test my interface in IB, but when I do it in my own app I get this error:

*** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object

You can't send -setObject:forKey: to an immutable dictionary or else it will raise the above exception. Just because you declare something to be an NSMutableDictionary doesn't mean it is a mutable dictionary; if you call something that returns an NSDictionary, and treat it like a mutable dictionary, then you'll run into problems like the above. Instead, you need to do this:

NSMutableDictionary *someDictionary = [[someOtherDictionary mutableCopy] autorelease];

Then someDictionary will be a mutable copy of someOtherDictionary, and you can use that. But if your intention is to set some keys in a dictionary obtained from the user defaults, then you'll need to remember to put the dictionary back into the user defaults when you're done making changes.

Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSArrayController with User Defaults (From: Johan Kool <email@hidden>)

  • Prev by Date: API for burning CDs?
  • Next by Date: Re: API for burning CDs?
  • Previous by thread: NSArrayController with User Defaults
  • Next by thread: Compiling NSAppleScript with getuid = 0
  • Index(es):
    • Date
    • Thread