Warning when using the BOOL variable in objective-c

I'm trying to initialize my BOOL variable to YES, but it gives me this warning .. not quite sure what to do .. it still works fine, but just wondering how I can get rid of the warning.

I have a variable initialization in a header like this

//. H

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

Then I try to set it as YES (this also I get a warning)

 self.removeActivityIndicator = YES; 

The warning reads:

incompatible integer with pointer conversion passing "BOOL" (aka 'signed char') to a parameter of type 'BOOL *' (it is also signed char * ')

+6
source share
3 answers

The warning is true; you specified the variable as BOOL * (pointer to BOOL), which is almost certainly not what you want. Remove * from ad.

+29
source

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

  • change it to BOOL removeActivityIndicator;
  • Divide it: *(self.removeActivityIndicator) = YES;
+4
source

You pointed to BOOL , which is a primitive type. Remove the extra * before the remoteActivityIndicator .

+3
source

Source: https://habr.com/ru/post/902785/


All Articles