Object vanished before it is removed?
Object vanished before it is removed?
- Subject: Object vanished before it is removed?
- From: Knut Lorenzen <email@hidden>
- Date: Sun, 10 Feb 2008 20:18:36 +0100
Hi all,
I am trying to loop through an NSMutableArray of
NSMutableDictionaries, extract archived NSColors, convert them to
hexValues and then remove the NSColor from the NSArray. Here's the code:
int row;
for (row = 0; row < [theArray count]; row++) {
NSMutableDictionary *testDic = [NSMutableDictionary
dictionaryWithDictionary: [theArray objectAtIndex: row]];
NSColor *bgColor = (NSColor *)[NSUnarchiver unarchiveObjectWithData:
[testDic valueForKeyPath:
@"OUTPUT_WINDOW_SETTINGS.NSBACKGROUND_COLOR"]];
[[testDic valueForKey: @"OUTPUT_WINDOW_SETTINGS"]
setObject: [bgColor hexadecimalValueOfAnNSColor]
forKey: @"BACKGROUND_COLOR"];
NSLog(@"%@ has the value %@", [testDic valueForKey: @"NAME"] ,
[testDic valueForKeyPath:
@"OUTPUT_WINDOW_SETTINGS.NSBACKGROUND_COLOR"]);
[[testDic valueForKey: @"OUTPUT_WINDOW_SETTINGS"] removeObjectForKey:
@"NSBACKGROUND_COLOR"];
}
The problem is, after the first loop, the log reads:
Testdata1 has the value <040b7374 7265616d 74797065 6481e803 84014084
8484074e 53436f6c 6f720084 84084e53 4f626a65 63740085 84016301
84046666 66660000 010186>
Testdata2 has the value (null)
*** -initForReadingWithData: nil argument
But Testdata2 does exist and has the appropriate value (checked with
NSLog). What am I missing?
Cheers,
Knut
_______________________________________________
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