Re: [Mysql-cocoa-users] testing for a NULL value from the db
Brought to you by:
sergecohen
From: Serge C. <ser...@us...> - 2004-07-22 21:11:44
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hash: SHA1=0D =0D Hi there;=0D =0D You can also use the method isNSNull, which I have added as a category =0D= of NSObject (so works on any object):=0D =0D if ([[row objectForKey:@"COMMENT"] isNSNull]) {=0D ... what to do if it's null=0D }=0D else {=0D ... what to do if it a proper object (NOT NULL)=0D }=0D =0D Serge.=0D =0D Le 22 juil. 04, =E0 18:31, John Guy a =E9crit :=0D =0D > This came up a while ago (a long time ago) and I can't exactly =0D > remember the outcome, also I am using an old version of the framework =0D= > at the moment.=0D >=0D > the NSNull is a special Cocoa object to represent Null items.=0D >=0D > you can do something like=0D >=0D > if ([[row objectForKey:@"COMMENT"] isKindOfClass:NSNull])=0D > {=0D > // process the null object properly=0D > }=0D >=0D > I think that should help=0D > (have a look at the Cocoa documentation for NSObject for = isKindOfClass)=0D >=0D > JOhn=0D >=0D >=0D > On 22 Jul 2004, at 17:14, John Spicer wrote:=0D >=0D >> I have some rows in the database table that are nulls.=0D >>=0D >> I am trying to do an assignment like this:=0D >>=0D >> [thisOne setCOMMENT:[row = objectForKey:@"COMMENT"]];=0D >>=0D >>=0D >> but later on in assignments to elements I get an error of=0D >>=0D >> *** -[NSNull length]: selector not recognized=0D >>=0D >> since it's a null and not a string.=0D >>=0D >> How do I test this coming from the db and set it to an empty string?=0D= >>=0D >> I tried this=0D >>=0D >> if ([row objectForKey:@"COMMENT"] !=3D NULL)=0D >>=0D >>=0D >> but it's not a null, it's an object with a name of NSNull which I =0D >> don't know how to deal with!=0D >>=0D >> Help!=0D *******************************************=0D Serge Cohen=0D =0D GPG Key ID: 9CBB58FB=0D *******************************************=0D -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (Darwin) iD8DBQFBAC2K5EPeG5y7WPsRAq/pAKDigw9KZ7JJ/MI/1CSOAugaXWaoqwCfbNcZ SyqpV3KU7zo63FQPTfYxOsE=3D =3DPZeV -----END PGP SIGNATURE----- |