Shade Shade - 3 months ago 8
iOS Question

BOOL wrapper? Make an object of `BOOL` value. (Objective-C)

How do I wrap a

BOOL
in an object type in Objective-C?

I want to store a
BOOL
in the
userInfo
object of an
NSTimer
. How do I wrap it?

Answer
NSNumber *boolForUserInfo = @YES; // or [NSNumber numberWithBool:YES] the old way
[userInfo setObject:boolForUserInfo forKey:@"myBool"];

Retrieve with:

[[userInfo objectForKey:@"myBool"] boolValue];