Reputation: 7310
I was trying to use a BOOL
from an object in an if else
comparison and I got a warning when I wrote player.isUp
suggesting I use player->isUp
Why can't I use dot notation for object BOOLs? And what does ->
mean??
Upvotes: 0
Views: 142
Reputation: 104698
Why can't I use dot notation for object BOOLs?
You can, provided there is a property declared.
And what does -> mean??
This is direct member access to the ivar -- it does not use the getter/setter, nor does it use objc messaging. In this case: object->ivar
, you will likely get an EXC_BAD_ACCESS
if object
is nil
.
Upvotes: 3
Reputation: 5313
In order to use dot notation, you need to define isUp as a property of the class that your object belongs to. The arrow is standard C syntax for accessing a value from a struct pointer.
Upvotes: 3