简体   繁体   中英

Parse iOS SDK: How to check for BOOLean?

What is the way one would go about getting this idea to work?

if ([[PFUser currentUser][@"isBool"]==YES) {

    //do something

}

I just tried this and it does not work.

A PFUser is basically an NSDictionary , and you can't store BOOL values directly in a dictionary. It is most likely casted as an NSNumber , and you need to call -boolValue to access it.

This should work:

if ([[[PFUser currentUser] objectForKey:@"isBool"] boolValue]) {
    // do something
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM