• 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: Robin Hermann <email@hidden>
  • Date: Sun, 16 Jan 2005 23:19:03 +0100

Did it like this:

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


Any better ideas are welcome.

Robin Hermann

On 16 jan 2005, at 23:05, Robin Hermann wrote:

I have the following situation:

I get data from a MySQL TEXT-field and put the text it in a NSScrollview:

NSData *note = [record objectForKey:@"notes"];
unsigned long len = [note length];
unsigned char noteBuffer[len];
[note getBytes:noteBuffer];
NSString *noteString = [NSString stringWithCString:noteBuffer length:len];
[notes setString:noteString];

But when there is no text I get the following message in the log:
-[NSNull length]: selector not recognized


How can I avoid this?

Robin Hermann _______________________________________________
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
 _______________________________________________
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: Mark Ritchie <email@hidden>
References: 
 >NSData testing for NULL (From: Robin Hermann <email@hidden>)

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