C.Johns
C.Johns

Reputation: 10245

warning when using BOOL variable in objective-c

I am trying to initalize my BOOL variable to YES but its giving me this warning.. not quite sure what to do.. it still seems to be working fine but just wondering how I can get rid of the warning.

I have initalize the variable in the header like this

//.h

BOOL *removeActivityIndicator;
//..
@property (nonatomic, assign) BOOL *removeActivityIndicator;

Then I try to set it to YES like so (this is also where I get the warning)

self.removeActivityIndicator = YES;

The warning says :

incompatible integer to pointer conversion passing 'BOOL' (aka 'signed char') to paramater of type 'BOOL *' (aka 'signed char *')

Upvotes: 7

Views: 10135

Answers (3)

Rob Napier
Rob Napier

Reputation: 299703

You've made a pointer to a BOOL, which is a primitive type. Remove the extra * in front of remoteActivityIndicator.

Upvotes: 3

MByD
MByD

Reputation: 137442

removeActivityIndicator is a char pointer, and you assigns a char to it, so either:

  1. change it to be BOOL removeActivityIndicator;
  2. Dereference it: *(self.removeActivityIndicator) = YES;

Upvotes: 4

user149341
user149341

Reputation:

The warning is correct; you've declared the variable as a BOOL * (a pointer to a BOOL), which is almost certainly not what you want. Remove the * from the declaration.

Upvotes: 31

Related Questions