• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSData testing for NULL [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSData testing for NULL [SOLVED]
      • From: "M. Uli Kusterer" <email@hidden>
References: 
 >NSData testing for NULL (From: Robin Hermann <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Robin Hermann <email@hidden>)

  • Prev by Date: Colorsync Utility graphical feature
  • Next by Date: Re: Colorsync Utility graphical feature
  • Previous by thread: Re: NSData testing for NULL [SOLVED]
  • Next by thread: Re: NSData testing for NULL [SOLVED]
  • Index(es):
    • Date
    • Thread