I have JSON response from server, and there is bool variable coming in format 1=true, 0=false.
In my code I do this:
My first try:
NSString *bolean=[dict objectForKey:@"featured"];
if ([bolean isEqualToString:@"1"]) // here application fails...
{
BOOL *a=[bolean boolValue];
[newPasaka setFeatured:a];
}
else
{
BOOL *a=[bolean boolValue];
[newPasaka setFeatured:a];
}
My second try:
Here it thinks that 1 = NO, 0 = NULL
NSString *bolean=[dict objectForKey:@"featured"];
if ([bolean boolValue]) //if true (1)
{
BOOL *a=[bolean boolValue];
[newPasaka setFeatured:a];
}
else //if false (0)
{
BOOL *a=[bolean boolValue];
[newPasaka setFeatured:a];
}
How to workaround this?
And my class also handles this crazy.. When i setFeatured to YES
- it sets NO
. When i set NO
- it sets null.
Here is my class:
*.h
@property BOOL *featured;
*.m
@synthesize featured;