A common iOS error-handling pattern in Objective-C is to return a BOOL result and to pass an NSError by reference. In order to find out if the message had an error, you check the bool, and then if the method failed, you use the NSError object to find out why. In some cases, the NSError could contain garbage if you don’t check the BOOL first, so Apple recommends always checking the result before checking the NSError:
However, Couchbase Lite doesn’t always follow that approach. Consider CBLQuery.run, which takes an NSError reference and returns a CBLQueryEnumerator:
There are reasons why you might pursue a different API style, but it would be nice if you were super-clear on the contract. Can we always rely on good values in the NSError object here, or do we need to check CBLQueryEnumerator first? I’m assuming not, since I don’t see a good way to check CBLQueryEnumerator for failure.
So I guess that to check for errors, you check the NSError first, and then check the CBLQueryEnumerator after that if the NSError shows no error?