• 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: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]


  • Subject: Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
  • From: Robin Hermann <email@hidden>
  • Date: Mon, 17 Jan 2005 15:54:32 +0100

Mark,

Thank you for making this as clear as possible.
Now using:

NSData *note = [record objectForKey:@"notes"];
if (note != Nil && [note isKindOfClass:[NSData class]]) {
unsigned long len = [note length];
unsigned char noteBuffer[len];
[note getBytes:noteBuffer];
NSString *noteString = [NSString stringWithCString:noteBuffer length:len];
[notes setString:noteString];
}

and working perfect ;-)

Regards,
Robin Hermann


On 17 jan 2005, at 14:22, Mark Ritchie wrote:

On Jan 17, 2005, at 2:16 AM, Robin Hermann wrote:
Can't find very much info (Apple Docs, Google) on NULL, Nil and nil though.

nil and Nil are defined in the Objective-C runtime header (excerpt below.)
As Uli pointed out, nil is typically used when you expect a pointer to an instance of an object. Nil is typically used when you expect a pointer to a class object.

The handy thing about nil is that you can legally send messages to nil in Objective-C.
[nil someMethodName] is quite legal and in fact, relied upon regularly.

My incorrect use of null is a failing from having done too much work in Java lately.

Hope that gives you some idea of nil and Nil.
Mark.


From: NSObjCRuntime.h
In /System/Library/Frameworks/Foundation.framework
...
#if !defined(nil)
#define nil (id)0
#endif

#if !defined(Nil)
#define Nil (Class)0
#endif
...

__
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: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
      • From: Brendan Younger <email@hidden>
References: 
 >NSData testing for NULL (From: Robin Hermann <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Robin Hermann <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Mark Ritchie <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: "M. Uli Kusterer" <email@hidden>)
 >Re: NSData testing for NULL [SOLVED] (From: Robin Hermann <email@hidden>)
 >Definition of Nil and nil was: NSData testing for NULL [SOLVED] (From: Mark Ritchie <email@hidden>)

  • Prev by Date: Having NSSecureTextField display the hidden text
  • Next by Date: Re: Having NSSecureTextField display the hidden text
  • Previous by thread: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
  • Next by thread: Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
  • Index(es):
    • Date
    • Thread