Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios boolean var declaration

I declared a function with boolean input var. I get no errors. However, when calling it from another controller, notification appears: "incompatible integer to pointer conversion sending'BOOL' to parameter of type BOOL". What am I doing wrong? Thanks.

- (void)composeBar: (BOOL *)savePars

from other view:

AppDelegate *localFunction = [[UIApplication sharedApplication] delegate];

[localFunction composeBar:YES];
like image 804
Jaume Avatar asked Feb 03 '12 19:02

Jaume


1 Answers

BOOL* isn't a boolean. It's a pointer to a boolean. Just use

- (void)composeBar:(BOOL)savePars

You're likely confused because all Obj-C objects are declared with the *, but that's because they're actually pointers. However, BOOL is not an object, it's actually just a char which holds 0 or 1. Just as you would use int for an integer instead of int* (or in more idiomatic code, NSInteger), you use BOOL instead of BOOL*.

like image 62
Lily Ballard Avatar answered Nov 15 '22 09:11

Lily Ballard