"LValue" does not mean what I think it means?

In the following code:

_imageView.hasHorizontalScroller = YES;
_imageView.hasVerticalScroller = YES;
_imageView.autohidesScrollers = YES;

NSLog(@"scrollbar? H %p V %p hide %p", 
      &(_imageView.hasHorizontalScroller), 
      &(_imageView.hasVerticalScroller),
      &(_imageView.autohidesScrollers));

I get an error message:

Controller.m:143: error: lvalue required as unary '&' operand
Controller.m:144: error: lvalue required as unary '&' operand
Controller.m:145: error: lvalue required as unary '&' operand

Note that I use these variables as lvalues ​​immediately before the lines and ...

How can he complain that the value is not an lvalue value right after I assigned it without errors? is this related to the magic getters / setters that the target C creates?

I think I need to explain some context to explain why I am trying to get the address:

in the previous SO message, I showed the same code by typing% d and finding that the properties were still 0 after the assignments. So, I decided that I would try to get the addresses of the properties to see where they are stored, and maybe , I can understand why I do not successfully appoint them, and then it happened.

, , , , , , obj-c ( , SO - ,

BOOL b = [_imageView setHasVerticleScroller: YES]

,

BOOL b = _imageView.hasVerticalScroller = YES;

.

+5
2

_imageView.hasHorizontalScroller = YES; - imageView - , setter:

[_imageView  setHasHorizontalScroller:YES]; // Equivalent of your code.

, getter BOOL. mipadi & NSLog.

properties obj-c.

: , , :

BOOL b = _imageView.hasVerticalScroller = YES;
+2

100%, .

BOOL, ( ) unsigned char Objective-C. (, int, , - .) , (&) . ivars ; . , BOOL , -, - .

, :

static int returnOne(void)
{
    return 1;
}

// Later...

NSLog(@"returnOne is %p", &returnOne());    // Oops, the return value of returnOne has no address!

:

NSLog(@"scrollbar? H %d V %d hide %d", 
  _imageView.hasHorizontalScroller, 
  _imageView.hasVerticalScroller,
  _imageView.autohidesScrollers);
+3

All Articles