Re: Feeding NSUnarchiver bad data can cause crash
Re: Feeding NSUnarchiver bad data can cause crash
- Subject: Re: Feeding NSUnarchiver bad data can cause crash
- From: "Douglas A. Welton" <email@hidden>
- Date: Thu, 03 Jun 2004 07:14:14 -0400
Jeremy,
check out the cocoa doc for Archives and Serialization:
<
http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/index.h
tml#//apple_ref/doc/uid/10000047i>
Here's the snippet that I might use to check an unarchived library of data.
NOTE: this is being written in e-mail... your mileage may vary ;^}
NS_DURING
Library = [[NSUnarchiver unarchiveObjectWithFile: Target_File] retain];
NS_HANDLER
//+
// Put up an error dialog for the user and perform
// an alternate initialization for the Library
//-
NSBeginInformationalAlertSheet( @"Oak Library", @"Continue", nil, nil,
Main_Window, nil, NULL, NULL, nil,
@"Error message goes here" );
Library = [[[Oak_Sources alloc] init] retain];
NS_ENDHANDLER
later,
douglas
on 6/3/04 6:22 AM, Jeremy Dronfield at email@hidden wrote:
>
On 2 Jun 2004, at 9:27 pm, Douglas A. Welton wrote:
>
>
> Jeremy,
>
>
>
> Check out the section on "Handling Exceptions" in the Cocoa doc.
>
> NS_DURING,
>
> NS_HANDLER, and NS_ENDHANDLER are your friend ;^}
>
>
I haven't had any luck with exception handling on this. Documentation
>
and example code for exception handling seems hard to come by. Let's
>
say I do this:
>
>
NS_DURING
>
theText = [NSUnarchiver unarchiveObjectWithData:plaintext];
>
>
or
>
>
@try {
>
theText = [NSUnarchiver unarchiveObjectWithData:plaintext];
>
}
>
>
What error precisely am I looking for? What goes in the if() statement?
>
>
Regards,
>
-Jeremy
_______________________________________________
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.