Re: NSData testing for NULL [SOLVED]
Re: NSData testing for NULL [SOLVED]
- Subject: Re: NSData testing for NULL [SOLVED]
- From: Mark Ritchie <email@hidden>
- Date: Sun, 16 Jan 2005 21:23:57 -0500
Hi Robin,
I always choose to store a result and test it rather then ask for it
twice
and I tend to check that each line of code has worked before I proceed.
So, I would structure my code something like this:
NSData *note = [record objectForKey:@"notes"];
if ((note != null) && [note isKindOfClass:[NSData class]){
...
}
Note that in the past I would have used the following:
if ((note != null) && ( note != [NSNull null])){
...
}
however I no longer see a reference in the docs which state that
instances of
NSNull are guaranteed to be unique. This used to be the case and then
lots
of things broke when one release didn't do the correct replacement
during
unarchiving. So, it's probably a little safer to use the code above.
Good luck!
Mark.
__
Mark Ritchie, email@hidden 416-843-5479
Software Developer, Apple Certified Developer Trainer
WebObjects, Cocoa, Mac OS X and Mac OS X Server
Diamond Lake Consulting Inc., Toronto, Ontario, Canada
_______________________________________________
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