• 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: NSNull and @""
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNull and @""


  • Subject: Re: NSNull and @""
  • From: Seth Willits <email@hidden>
  • Date: Fri, 10 Oct 2008 17:58:53 -0700

On Oct 10, 2008, at 5:40 PM, Ian Joyner wrote:

I'm just trying to work out what NSNull really is in the Cocoa context. Is it an object in Cocoa?


As I said, yes. It's truly an object. (A singleton, as well.)



Since NSNull may be a "valid" value of any other type, is it counted as a subtype of every other type (hence the ultimate subclass)? I think a good and simple (one that doesn't make my brain hurt) definition of NSNull is important in order to ensure software correctness.

Woah. Talk about brain hurt. You're thinking about this far too much.

There's no inheritance, there's no nothing. It's an object. It's absolutely in no way different than you creating your own IJNull class, and sticking an instance of it anywhere. It doesn't behave any differently.


As for use, the documentation says it pretty clearly:

"The NSNull class defines a singleton object used to represent null values in collection objects (which don’t allow nil values)."


You can't stick nil into dictionaries and arrays. So either you stick an empty string, an NSNumber with 0, etc if those are OK, or you can use NSNull.




--
Seth Willits




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSNull and @""
      • From: "Sean McBride" <email@hidden>
    • Re: NSNull and @""
      • From: "Stelian Iancu" <email@hidden>
    • Re: NSNull and @""
      • From: Ian Joyner <email@hidden>
References: 
 >NSNull and @"" (From: DKJ <email@hidden>)
 >Re: NSNull and @"" (From: Seth Willits <email@hidden>)
 >Re: NSNull and @"" (From: Ian Joyner <email@hidden>)

  • Prev by Date: Re: NSNull and @""
  • Next by Date: Re: NSNull and @""
  • Previous by thread: Re: NSNull and @""
  • Next by thread: Re: NSNull and @""
  • Index(es):
    • Date
    • Thread