On Sun, Nov 30, 2008 at 9:29 PM, Mahaboob <[EMAIL PROTECTED]> wrote: > Hi, > I'm using QuickLite database to hold some data. I created one column as > Boolean to hold the state of a Checkbox and I inserted the values to the > table. But whenever I'm retrieving the values from database the Boolean > value is return only 1 and so I can't set the state of the Checkbox > correctly. > I used the code to set the Boolean value to insert: > > NSNumber *defValue; > if([cbUseDefault state] == NSOnState) > defValue = [NSNumber numberWithBool:YES]; > else > defValue = [NSNumber numberWithBool:NO];
BTW, this can be simplified to: NSNumber *defValue = [NSNumber numberWithBool: [cbUseDefault state] == NSOnState]; > > And for retrieving I used: > > NSNumber * boolVal = [row valueForColumn:@"Contact.UseDefault"]; > if(boolVal>0) > [cbUseDefault setState:NSOnState]; > else > [cbUseDefault setState:NSOffState]; > > Where I got wrong? How can I solve this? You want: NSNumber *number = [row valueForColumn:@"Contact.UseDefault"]; if([number boolValue]) [cbUseDefault setState:NSOnState]; else [cbUseDefault setState:NSOffState]; -- Clark S. Cox III [EMAIL PROTECTED] _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]