On Mar 3, 2009, at 1:33 PM, Quincey Morris wrote:
I don't know of any documented API contract that says [NSMenu initWithTitle:] never fails, so checking the returned value seems prudent.
In the case of Apple's documentation, it's the other way around. Unless the documentation mentions that it may return nil, it's guaranteed to return something. See NSPipe's documentation for such an example.
In addition, I've always assumed that 'alloc' could potentially return nil. In that case, the result of the initialization would be nil too, and so needs to be checked. (Is that wrong? Is an exception thrown if there is no memory available? If so, is that documented somewhere?)
It doesn't seem to be documented, but I think it will return nil only if (1) there was not enough contiguous RAM in the program's VM space to allocate the object, or (2) there was, but the user has run out of disk space for swap files. But if this happens, the program is pretty much screwed anyway, because it's going to crash. No exception is thrown, but the function szone_error() is called, and you can break on that.
Nick Zitzmann <http://www.chronosnet.com/> _______________________________________________ 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 arch...@mail-archive.com