Why doesn't oc use try catch

To put it simply, although Apple provides both error handling (NSError) and exception handling (exception) mechanisms, Apple encourages developers to use NSError to handle recoverable errors during program operation. Exceptions are recommended for handling unrecoverable errors.

There are several reasons. In the case of non-gc, exceptions are easy to cause memory management problems (the document describes that even under arc, it is not safe); the use of blocks in exceptions causes additional overhead, low efficiency, etc. In addition, this is true Is the habit of Cocoa developers.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944521&siteId=291194637