Consider the following Cocoa/Obj-C code snippets:
MyClass *obj;
@try {
[obj doSomething];
}
@catch (NSException * e) {
NSLog(@"Exception occurred: %@", [e description]);
}
@finally {
[obj cleanUp];
}
and
MyClass *obj;
@try {
[obj doSomething];
}
@catch (NSException * e) {
NSLog(@"Exception occurred: %@", [e description]);
}
[obj cleanUp];
In what circumstances will the first snippet result in [obj cleanUp]
being called, while the second won't result in [obj cleanUp]
being called? In other words, in what circumstances is @finally
non-redundant when using Cocoa Exception Handling?