I have an object with a dictionary property defined as: @property (nonatomic, retain) NSMutableDictionary* myDict;
This gets set when it is received via an AppleEvent from another application. Multiple threads in the receiving app need to read (the threads never write, only read) from the Dictionary like: [self setValueOne:[[myDict objectForKey:kValueOneKey] intValue]]; [self setValueTwo:[[myDict objectForKey:kValueTwoKey] intValue]]; I need to be able to set a new myDict and not have it happen between the reading of different values from the dictionary by other threads. Should this be done best with a @synchronize around a copy: @synchronize(myDict) { myCopy = [[NSDictionary alloc] initWithDictionary:myDict copyItems:YES]; } [self setValueOne:[[myCopy objectForKey:kValueOneKey] intValue]]; [self setValueTwo:[[myCopy objectForKey:kValueTwoKey] intValue]]; [myCopy release]; This would seem to ensure that valueOne and valueTwo were obtained from the same instance of a given dictionary and that the dictionary did not change in between the reading and setting of these two dictionary content objects. I need to avoid valueOne and valueTwo coming from two different instances of myDict. Thanks, Trygve _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com