Re: preventing bad memory access
Re: preventing bad memory access
- Subject: Re: preventing bad memory access
- From: Kyle Sluder <email@hidden>
- Date: Thu, 20 Oct 2011 22:20:28 -0700
On Oct 20, 2011, at 8:56 PM, Don Quixote de la Mancha <email@hidden> wrote:
> For C++, you would need to throw an exception on I/O error, then write
> exception-safe code. I have not yet really figured out the right way
> to do the equivalent for Objective-C, because Objective-C exceptions
> don't work like C++ exceptions do.
This is what NSError is for. You would return NO (or some other similar value indicating unsuccessful completion) and return an NSError by reference.
FWIW, Objective-C exceptions do behave like C++ exceptions (the exception machinery is the same on modern runtimes), but are not _used_ like C++ exceptions. Throwing an exception from Objective-C code is used to signal programmer error, not general failure to complete an operation.
--Kyle Sluder_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden