Re: nil pointers
Re: nil pointers
- Subject: Re: nil pointers
- From: Bill Bumgarner <email@hidden>
- Date: Tue, 11 Jul 2006 10:59:57 -0700
On Jul 11, 2006, at 10:41 AM, Uli Kusterer wrote:
Am 11.07.2006 um 19:06 schrieb Bill Bumgarner:
NSArray *arrayIAmGoingToGetFromSomewhereMaybe = (id) 0x1;
Whoa! I think I'm going to request that that be made an official
constant:
#define INVALID ((id) 0x01)
that guarantees an access exception. For platforms that have no
address that's guaranteed to be invalid, they could always create a
singleton that just dies on receiving any message.
You could likely also go for ((id) -1)-- whatever the magic cast
would be-- as that should produce an address that cannot possibly be
a pointer to anything as it is the very last byte of address space
(no room for the other 3 bytes of the address).
For my purposes, 0x01 has always worked quite well. I have often
used it in my designated initializers to ensure that I'm not making
unfortunate assumptions about the internal state of my object. This
also makes transitioning from single use objects to reuse-through-
reset much easier as you know that nothing depends on iVars being set
to 0 upon instantiation.
b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden