>> You should not set `*outError` when you have no errors.
This is a side issue, since this thread is not really about Obj-C, but just to clarify a subtle point:
It is not wrong to set "*outError" when there is no error. The API contract for Obj-C error handling only requires that it be set to a valid error when the method returns "nil" or "NO" (false). If there is no error, the caller cannot assume that its NSError* parameter hasn't been changed.
This trips up incautious programmers up, because they'll do something like this:
NSError* error = nil;
result = [self doSomethingThatCouldFailWithError: &error];
if (error != nil)
… // handle the error
This pattern is a recipe for disaster, because "error" may be non-nil even on success.
However, you are correct in that the original code is not very elegant. In the first case, the error is too generic and unhelpful, and in the second case the error is unnecessary because the method always returns YES.