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).

你可能感兴趣的:(ios开发)