Sorry for my careless, I though Jens was talking about the `read' part. However, as I said, the error occurred when reading not when writing. So it was not because > NSKeyedArchiver returned nil but because `[NSKeyedUnarchiver unarchiveObjectWithData:data]' returned nil, and my `readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError' returned NO without setting `outError' (thanks Jens let me learn this point). OK. Now I'm just wondering why `[NSKeyedUnarchiver unarchiveObjectWithData:data]' returnes nil, since I've saved the data without any error as I can see. Thanks a lot if you or others can give me some more hint.
On Fri, Apr 25, 2008 at 4:29 PM, Kyle Sluder <[EMAIL PROTECTED]> wrote: > On Fri, Apr 25, 2008 at 4:11 AM, an0 <[EMAIL PROTECTED]> wrote: > > Thanks. But it seems you haven't read to the end. As I said in my first > mail: > > > > > Besides, I found the value returned by [NSKeyedUnarchiver > > > unarchiveObjectWithData:data] was nil, but I didn't understand why, > > > since it was normal when I saved the file using [NSKeyedArchiver > > > archivedDataWithRootObject:view.drawing]. > > But you apparently haven't comprehended Jens' message. You're not > setting *outError to anything, so whoever is calling your method is > seeing that you've returned NO and is expecting whatever it passed in > as outError to point to an NSError object. Unfortunately this is not > the case and whatever was in that memory location is receiving bogus > messages -- particularly, -localizedFailureReason, which is an NSError > method. > > In short, you're breaking the contract for messages which take an > NSError**. Set *outError to an NSError object (or nil if you're lazy) > if you're going to return a value that signifies an error. > > --Kyle Sluder > _______________________________________________ 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 [EMAIL PROTECTED]