Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage a BOOL variable?

I'm using a variable "volume"

@property BOOL * volume;

to set Volume On (YES) or Off (NO)

- (IBAction)manageVolume:(UIButton *)sender {
    if (_volume == TRUE) {
        _volume = !_volume; 
//      code...
    } else {
        _volume = !_volume;
//      code...
        }
    }

It Works but it return three alerts:

  • if (_volume == TRUE) { returns Comparison between pointer and integer ('BOOL *' (aka 'signed char *') and 'int')

  • _volume = !_volume; returns Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'int'

How can I solve? Thank you!

like image 915
Matte.Car Avatar asked Jan 17 '26 21:01

Matte.Car


1 Answers

Your property definition is wrong. It should not be a pointer to a BOOL, it should just be a BOOL:

@property BOOL volume;
like image 140
Wain Avatar answered Jan 19 '26 17:01

Wain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!