2

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!

Amar
  • 13,173
  • 7
  • 52
  • 70
Matte.Car
  • 1,987
  • 4
  • 22
  • 40

1 Answers1

16

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

@property BOOL volume;
Wain
  • 118,043
  • 14
  • 134
  • 151
  • Right! Thank you very much! – Matte.Car Oct 20 '13 at 12:06
  • Also worth mentioning is that appropriate BOOL values include `YES` and `NO`, not `true` and `false`. You should see [this thread](http://stackoverflow.com/questions/541289/objective-c-bool-vs-bool) about why that is significant. – Holly Oct 20 '13 at 13:18