Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cast a BOOL to id in Objective-C

This is my code:

[delegate performSelectorOnMainThread:@selector(setVariablePremierAffichage:) withObject:TRUE waitUntilDone:NO];

The problem is that the argument "withObject" only takes an "id" type, so, how can I cast my value "TRUE" to an id type? I also use ARC memory management in Xcode for iOS 5.

like image 379
Alex Avatar asked Dec 19 '11 17:12

Alex


1 Answers

Pass an NSNumber. Use boolNumber = [NSNumber numberWithBool:TRUE]. Your method should be defined as:

-(void)setVariablePremierAffichage:(NSNumber *)boolNumber
{
    BOOL value = [boolNumber boolValue];
    // do something
}
like image 126
XJones Avatar answered Nov 01 '22 19:11

XJones