iOS开发中得一些记录

没看明白之一:

Error handling

When methods return an error parameter by reference, check the returned value, not the error variable.

Preferred:

NSError *error = nil;
if (![self trySomethingWithError:&error]) {
    // Handle Error
}

Moreover, some of Apple's APIs write garbage values to the error parameter (if non-NULL) in successful cases, so checking the error can cause false negatives (and subsequently crash).

posted @ 2015-01-02 11:22  memorecool  阅读(128)  评论(0编辑  收藏  举报