I'm getting a warning: "Return makes pointer from integer without a cast" for this method...
+(BOOL *)getBoolFromString:(NSString *)boolStr
{
if(boolStr == @"true" || boolStr == @"1"){
return YES;
}
return NO;
}
I'm getting a warning: "Return makes pointer from integer without a cast" for this method...
+(BOOL *)getBoolFromString:(NSString *)boolStr
{
if(boolStr == @"true" || boolStr == @"1"){
return YES;
}
return NO;
}
BOOL is not a class or object, so returning a pointer to a BOOL is not the same as returning a BOOL.
You should remove the * in +(BOOL *)
and everything will be ok.
To get a BOOL from an NSString, all you need to do is send a -boolValue
message, like so:
NSString *myString = @"true"; // or @"YES", etc.
BOOL bool = [myString boolValue];
Besides what @Jasarien and @jlehr have said, you have a problem with this:
(boolStr == @"true" || boolStr == @"1")
That's doing pointer comparison, not object equality. You want:
([boolStr isEqualToString:@"true"] || [boolStr isEqualToString:@"1"])