Re: Exception handling
Re: Exception handling
- Subject: Re: Exception handling
- From: ryan <email@hidden>
- Date: Tue, 28 Oct 2003 22:41:25 -0800
This is ObjectiveC exception handling. If you visit:
/Developer/Documentation/Cocoa/Conceptual/ObjectiveC/index.html
View 'the objective c language' and then 'exceptions', here is the
example:
Cup *cup = [[Cup alloc] init];
@try {
[cup fill];
}
@catch (NSException *exception) {
NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
}
@finally {
[cup release];
}
to throw an exception, do:
NSException * exception = ... ;
@throw exception ;
The documentation suggests that exceptions is available only on Mac OS
X 10.3. I recall seeing exceptions on Jaguar/Project Builder.
Anyone want to expand on support of ObjC exceptions? I thought it was
available at least on 10.2...
-ryan
I note that since ObjC objects can only realistically be created on the
heap, you don't have to work about 'unwind-protect' to call destructor
of stack objects. There are some useful techniques with auto
destructing stack objects which might be nice, but hey :-)
PS: If you use @synchronized you incur the cost of a @try/@catch. The
cost isn't entirely trivial either.
On Oct 28, 2003, at 8:21 PM, Martin-Gilles Lavoie wrote:
> For the life of me, I can't remember the syntax given for the new
> exception handling in Panther.
>
> It's something in the form
>
> @try
>
> @catch
>
> @foobar
>
> All documentation on Apple's site still point to the old (deprecated)
> NSDuring thing.
>
> Anybody remembers?
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.