NSArrayController
NSArrayController
- Subject: NSArrayController
- From: Johan Kool <email@hidden>
- Date: Thu, 15 Apr 2004 09:36:15 +0200
Hello,
In a simple app I am trying to get the content of a NSArrayController
saved. Saving seems to work, but opening not. My tableview doesn't get
updated with the saved data, also not after forcing a reloadData.
Can someone give me a pointer as to what I do wrong? This is the code I
use in MyDocument:
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
NSKeyedArchiver *archiver;
NSMutableData *data = [NSMutableData data];
archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutable
Data:data];
[archiver encodeObject:[mainArrayController content]
forKey:@"MyContent"];
[archiver finishEncoding];
return data;
[archiver release];
}
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
NSMutableArray *mutArray;
NSKeyedUnarchiver *unarchiver;
unarchiver = [[NSKeyedUnarchiver alloc]
initForReadingWith
Data:data];
mutArray = [unarchiver decodeObjectForKey:@"MyContent"];
NSLog([mutArray description]); // This logs expected results
[mainArrayController willChangeValueForKey:@"content"]; // Should
not be necessary?
[mainArrayController setContent:mutArray];
[mainArrayController didChangeValueForKey:@"content"]; // Should
not be necessary?
[unarchiver finishDecoding];
[unarchiver release];
return YES;
}
Thanks already!
Johan
_______________________________________________
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.