On 29 Nov, 2010, at 19:27, Graham Cox wrote: > > On 30/11/2010, at 1:59 PM, Rainer Standke wrote: > >> The intended behavior is not to get anything if the conditions are not met. >> >> >> Is this kosher? Do I have to do any kind of clean-up after doing something >> like that? > > > Yes, it's OK to do this. As it's your own class, you can do what you like - > typically you'd just document its behaviour (returns nil if x,y, and z are > not met) if anyone else is likely to use it. > > The only thing to be concerned with is correct memory management, which just > follows the usual rules. > > Returning nil, even unexpectedly, is usually 'safe' in that messages to nil > are legal, and are either no-ops or return 0, so unlike C++, if you > inadvertently send a message to nil, it doesn't crash.
>> messages to nil are legal, and are either no-ops or return 0 this is not correct; there are more possibilities than 0 being returned. in most situations, sending a message to nil does indeed yield a return value of 0/nil. but that's not true all of the time: "Sending Messages to nil" <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocObjectsClasses.html> if these caveats are important to what you later choose to do with the result of a message sen to an object that may be nil, you may need to pay attention to whether said object is nil before bothering to use it. -- michael _______________________________________________ Cocoa-dev mailing list ([email protected]) 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]
