• 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
Re: NSArchiver? try again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArchiver? try again


  • Subject: Re: NSArchiver? try again
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 30 Aug 2001 11:15:00 +0200

Mark's,

>>>>>> Mark's Studio (MsS) wrote at Thu, 30 Aug 2001 10:19:19 +0200:
MsS> I have made 2 Classes Object1 and Object2 with all the NSCoder stuff
MsS> and in MyDocument i have one NSMutableArray Object1DB and that works
MsS> fine.
MsS>
MsS> But now i have another NSMutableArray Object2DB
MsS> but i can't figure out how to setup dataRepresentationOfType and
MsS> readFromFile if i have more than one object.

Containers are your friends.

MsS> - (NSData *)dataRepresentationOfType:(NSString *)aType
MsS> {
MsS> return [NSArchiver archivedDataWithRootObject:Object1DB];

return [NSArchiver archivedDataWithRootObject:[NSArray
arrayWithObjects:Object1DB,o2,nil]];

MsS> }
MsS>
MsS> - (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)docType
MsS> {
MsS> [self setObject1DB:[NSUnarchiver
MsS> unarchiveObjectWithFile:fileName]];
MsS> return YES;
MsS> }

NSArray *a=[NSUnarchiver unarchiveObjectWithFile:fileName];
[self set1:[a objectAtIndex:0]];
[self set2:[a objectAtIndex:1]];

Or use a dictionary, which is even more flexible. Or implement NSCoding in
your model and (un)archive directly the model.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


References: 
 >NSArchiver? try again (From: "Mark's Studio" <email@hidden>)

  • Prev by Date: Re: Abstract classes and methods
  • Next by Date: Re: Inherited constructors
  • Previous by thread: NSArchiver? try again
  • Next by thread: Re: Subject: Inherited constructors
  • Index(es):
    • Date
    • Thread