• 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: Feeding NSUnarchiver bad data can cause crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • embedding the DisclosableView framework
      • From: Michael Hanna <email@hidden>
    • Re: Feeding NSUnarchiver bad data can cause crash
      • From: Jeremy Dronfield <email@hidden>
References: 
 >Re: Feeding NSUnarchiver bad data can cause crash (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: Feeding NSUnarchiver bad data can cause crash
  • Next by Date: Debugging under 10.2
  • Previous by thread: Re: Feeding NSUnarchiver bad data can cause crash
  • Next by thread: Re: Feeding NSUnarchiver bad data can cause crash
  • Index(es):
    • Date
    • Thread