David David - 3 months ago 8
iOS Question

Comparing data from NSNumber CoreData iOS

I've got in CoreData a

@property (nonatomic, retain) NSNumber * hidden;

which is Boolean. I am trying using following code
[object valueForKey:@"hidden"]

How can I compare the returned value, to use it in
if()

if ([[object valueForKey:@"hidden"] isEqualToString:@"1"])

doesn't work

Answer

You can query the bool value of an NSNumber using [[object valueForKey:@"hidden"] boolValue] and that way you can do proper bool handling.

Comments