• 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
NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] initForWritingWithMutableData: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] 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.


  • Follow-Ups:
    • Re: NSArrayController
      • From: Hasan Diwan <email@hidden>
    • Re: NSArrayController
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: Install Program for Completed App
  • Next by Date: Re: Is NSDocument read outside init?
  • Previous by thread: Re: drawing on top of a NSMovieView?
  • Next by thread: Re: NSArrayController
  • Index(es):
    • Date
    • Thread