Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED]
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