• 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: Retrieving Boolean from database
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retrieving Boolean from database


  • Subject: Re: Retrieving Boolean from database
  • From: Mahaboob <email@hidden>
  • Date: Mon, 01 Dec 2008 12:22:04 +0530
  • Thread-topic: Retrieving Boolean from database

Thanks Clark Cox,
Now it is working fine.
I also need to retrieve all the values where this Boolean value is True.
I tried the  Query like both:
QuickLiteCursor * cursor = [db performQuery:[NSString stringWithFormat:
@"select * from Contact where UseDefault = 1 "]];
and
QuickLiteCursor * cursor = [db performQuery:[NSString stringWithFormat:
@"select * from Contact where UseDefault = YES"]];

But it is not working. How can I write the query for that ?

Thanks in advance
mahaboob

On 12/1/08 11:54 AM, "Clark Cox" <email@hidden> wrote:

> On Sun, Nov 30, 2008 at 9:29 PM, Mahaboob <email@hidden> 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];


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Re: Retrieving Boolean from database (From: "Clark Cox" <email@hidden>)

  • Prev by Date: Re: NSTextField as a CALayer
  • Previous by thread: Re: Retrieving Boolean from database
  • Next by thread: Programatically creating iDisk URL
  • Index(es):
    • Date
    • Thread