Re: [Mysql-cocoa-users] testing for a NULL value from the db
Brought to you by:
sergecohen
From: John G. <jo...@jl...> - 2004-07-22 16:31:15
|
This came up a while ago (a long time ago) and I can't exactly remember the outcome, also I am using an old version of the framework at the moment. the NSNull is a special Cocoa object to represent Null items. you can do something like if ([[row objectForKey:@"COMMENT"] isKindOfClass:NSNull]) { // process the null object properly } I think that should help (have a look at the Cocoa documentation for NSObject for isKindOfClass) JOhn On 22 Jul 2004, at 17:14, John Spicer wrote: > I have some rows in the database table that are nulls. > > I am trying to do an assignment like this: > > [thisOne setCOMMENT:[row objectForKey:@"COMMENT"]]; > > > but later on in assignments to elements I get an error of > > *** -[NSNull length]: selector not recognized > > since it's a null and not a string. > > How do I test this coming from the db and set it to an empty string? > > I tried this > > if ([row objectForKey:@"COMMENT"] != NULL) > > > but it's not a null, it's an object with a name of NSNull which I > don't know how to deal with! > > Help! |