#define SSYInitErrorP(_error_p) NSError* dummyError ; \
if (_error_p == NULL) { \
_error_p = &dummyError ; \
} \
* _error_p = nil ;
I use it like this, with an (NSError**)error_p:
SSYInitErrorP(error_p)
Besides setting *error_p to nil, which we agree is not necessary but
I "just like", it also assigns error_p to a dummy NSError* if NULL
was passed in, avoiding latent crashes.
One of the benefits of checking for (errorPtr == NULL) is that you
avoid creating the error object (along with its user info and such) if
the caller was not interested in the value.
So why not a macro that assigns the value instead:
#define AssignError(_error_p, err) if (_error_p) {*_error_p = err;}
BTW, Cocoa methods in general do not set the pointer to nil in case of
no error, but as Bill said, we haven't documented that behavior.
Ali
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]