Re: NSData testing for NULL [SOLVED]
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