• 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: Bindings/archiving: NSMutableDictionary errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings/archiving: NSMutableDictionary errors


  • Subject: Re: Bindings/archiving: NSMutableDictionary errors
  • From: Scott Anguish <email@hidden>
  • Date: Thu, 5 May 2005 03:21:37 -0400

Mike

If you're saving these in a PLIST format, I don't believe that unarchiving it as a mutable dictionary makes the deeper collections mutable.

you may need to do additional manipulation on the dictionary to make those deeper elements mutable before you start editing them.

Or, move to a custom object to hold your data. Or archive the dictionary rather than writeToFile: ing it


On May 5, 2005, at 1:12 AM, Mike Carter wrote:

Hello all.

I have a non-document Cocoa app that has at it's core a controller object with 2 mutable arrays that hold a collection of objects. I am writing this graph out to a file in the user's Application Data directory. When I create the objects through the main window, I can change all the settings as expected. When I start the app the next time, I load in the object graph and set the 2 arrays. From that point on, I can't make any changes to the two arrays. I get the following error:

2005-05-04 20:55:47.592 CCLS Route[4962] *** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object

I can, however, make changes to a couple other objects associated with the arrays. All the data is preserved correctly, just immutable.

@interface AppController : NSObject
{
// model
NSMutableArray *routes; // array of routelists
NSMutableArray *emps; // array of employees


    [...]

All of my data model objects use a NSMutableDictionary to store instance variables:

- (id) init {
if( self = [super init] ) {
NSArray * keys = [NSArray arrayWithObjects: @"name", @"owner", nil];
NSArray * values = [NSArray arrayWithObjects: @"Route list", [Employee employee], nil];


properties = [[NSMutableDictionary alloc] initWithObjects: values forKeys: keys];

        jobs = [[NSMutableArray alloc] init];
    }
    return self;
}

Where should I start looking for this error? When I initially input the data, there are no problems changing any of the values.
All of the key-value glue is made through bindings.


Thanks!

_________________________
Mike Carter
Aviate.Org :: Systems Admin
iChat: PilotMike :: PGP-0x71E5B44C

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


--
"William Cheeseman ... is said not to be a doofus in real life." - Roger Ebert, Chicago Sun-Times Online


Scott Anguish
email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Bindings/archiving: NSMutableDictionary errors (From: Mike Carter <email@hidden>)

  • Prev by Date: Weak linking broken?
  • Next by Date: Re: Setting the contents of an NSTokenField programatically
  • Previous by thread: Bindings/archiving: NSMutableDictionary errors
  • Next by thread: HexInputServer not working
  • Index(es):
    • Date
    • Thread