I’m new to Objective-C world. What I have noticed while studying some iOS/Mac apps is that try -catch is rarely used, if used at all.
For example in Java it is used almost all the time.
Why isn’t it so common in Objective-C ?
I’m new to Objective-C world. What I have noticed while studying some iOS/Mac apps
Share
There are a lot of SDK methods that take an
NSError**parameter and returnBOOL. To indicate an error they return false and feed an error back through the error parameter to communicate info.Exceptions are used, but generally for cases in which there is some failure at the runtime level – e.g. some object can’t handle a selector. Although it may seem contrary to what I just wrote, exceptions tend to indicate an error in design rather than a runtime error.
The
NSError**idiom is all you need for things such as failed URL connections, data conversions, etc, where an error condition exists but a program really shouldn’t be killed outright.Start reading: Error Handling Programming Guide