How to wrap BOOL in NSValue

An NSNumber is an NSValue subclass. As such,[NSNumber numberWithBool:YES] is already wrapping it in an NSValue for you.


Here's some example code to expand on answer by Joshua Weinberg.

➤ To convert a primitive BOOL to a pseudo-Boolean object:

NSNumber* isWinning = [NSNumber numberWithBool:YES];

➤ To convert a pseudo-Boolean object to a primitive BOOL:

BOOL winner = [isWinning boolValue];

See NSNumber class reference.


Actually NSNumber is a heavier-weight descendant of NSValue. If you actually want to use an NSValue here's how you'd do that:

BOOL bool_value = YES;
[NSValue valueWithBytes:&bool_value objCType:@encode(BOOL)]

Use an Objective-C literal:

@(YES)