Re: NSArrayController
Re: NSArrayController
- Subject: Re: NSArrayController
- From: Hasan Diwan <email@hidden>
- Date: Thu, 15 Apr 2004 09:35:55 -0700
Jonathan:
Slight issue I noticed:
On Apr 15, 2004, at 12:36 AM, Johan Kool wrote:
>
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]
>
initForWritingWithMutableData:data];
>
[archiver encodeObject:[mainArrayController content]
>
forKey:@"MyContent"];
>
[archiver finishEncoding];
>
>
return data;
>
[archiver release];
[archiver release] should come before the return statement.
>
}
>
>
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
>
{
>
NSMutableArray *mutArray;
>
NSKeyedUnarchiver *unarchiver;
>
>
unarchiver = [[NSKeyedUnarchiver alloc]
>
initForReadingWithData: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.
>
>
Hasan Diwan {
http://ibn.com/~hdiwan}
OpenPGP Fingerprint: 275D 0E84 550C D92A 4A56 732C 8528 2579 E6E9 4842
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.