• 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: Brendan Younger <email@hidden>
  • Date: Mon, 17 Jan 2005 09:34:39 -0600


On Jan 17, 2005, at 8:54 AM, Robin Hermann wrote:

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 ;-)

I'm sure it does work okay, but that's really not at all what you want to be doing. Apple has said repeatedly that the "C string" methods are going to be deprecated very soon because they depend on the current locale settings. Besides, what you're doing there is needlessly wasteful. There's no reason to allocate "noteBuffer" when you have -[NSString initWithData:encoding:] at your disposal, especially since you can then specify the encoding as well.

Brendan Younger
 _______________________________________________
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: Robin Hermann <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>)
 >Re: Definition of Nil and nil was: NSData testing for NULL [SOLVED] (From: Robin Hermann <email@hidden>)

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