Hey dkj -
The method -[NSArray writeToFile: atomically:] uses property list
serialization, and property lists support a fixed set of types. You
want to serialize your NSArray with an NSCoder, like NSKeyedArchiver,
and then read it back in with NSKeyedUnarchiver.
Take a look at these two methods:
-[NSKeyedArchiver archiveRootObject:toFile:]
-[NSKeyedUnarchiver unarchiveObjectWithFile:]
Good luck -
Jon Hess
On Jul 13, 2009, at 5:22 PM, DKJ wrote:
I've defined my own MyClass and made it conform to the NSCoding
protocol by adding methods like this:
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeInt:index forKey:@"index"];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
index = [decoder decodeIntForKey:@"index"];
return self;
}
I then put a bunch of these into an NSArray and try to save the
array like this:
NSString *path = [NSHomeDirectory()
stringByAppendingPathComponent:FILE_PATH];
BOOL didIt = [theArray writeToFile:path atomically:NO];
But nothing is saved: didIt = 0.
I must be missing a step somewhere. I've been looking at "Archives
and Serializations Programming Guide for Cocoa", and finding it
rather bewildering. A nudge in the right direction would be much
appreciated.
dkj
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.com
This email sent to jh...@apple.com
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com