Re: More Mac like handling of OS raised exceptions
Re: More Mac like handling of OS raised exceptions
- Subject: Re: More Mac like handling of OS raised exceptions
- From: Shawn Erickson <email@hidden>
- Date: Tue, 16 May 2006 07:37:04 -0700
On May 15, 2006, at 11:16 PM, Lon Giese wrote:
I just thought of something... I'm doing things the cocoa way:
read the file into NSData, get the pointer and parse the file...
read too much.. crash! NSData is supposed to simplify things.
What if I did it the old fashioned C way and just get a file
pointer from C. I don't remember: if you try to read too much with
a file pointer does the kernel crash? I think you just get an EOF
error.
NSData can tell you how much data it has. Use that as the overall
upper limit of what you can read from that instance of NSData. I see
no reason why you cannot trivially prevent this crash if it is coming
from a parser that you developed.
If you want to read from the file as you go instead of working with
one big NSData blob then use the Cocoa API that provides that
capability (or just use fopen, etc. directly).
Look at NSFileHandle [1] and NSInputStream [2].
-Shawn
[1] <http://developer.apple.com/documentation/Cocoa/Reference/
Foundation/ObjC_classic/Classes/NSFileHandle.html>
[2] <http://developer.apple.com/documentation/Cocoa/Reference/
Foundation/ObjC_classic/Classes/NSInputStream.html>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden