Tuesday, January 31, 2017
Objective-C provides complete try-catch-finally semantics for exception handling, with full stack unwinding. While Cocoa and CocoaTouch conventions discourage their use for runtime errors (originally for performance reasons), they are of common use also in Apple's frameworks for programmer errors (i.e. logic errors, such as accessing an out-of-bounds element of an NSArray).
Swift, on the other hand, provides similar do-try-catch semantics, but its errors (do not call them exceptions) are actually passed back as an out parameter and does not provide a stack unwinding mechanism. Moreover, as of Swift 3.x, Objective-C exceptions are left completely out of Swift error handling: they are uncatchable in this language, and cause a direct crash of the application or the service. For the rationale behind this choice, and its corresponding discussion, see this dissertation on the Swift GitHub repository.