1. If I have property named foo, should I have private instance variable named _foo or foo?
You don't have to create the instance variable yourself. A instance variable, prefixed with an underscore will automatically be created for you. Since you shouldn't access the variable directly (see below) you shouldn't care about what the underlying variable is called.
2. If I dont't create a private instance variable, just syntetize it. Then what variable should I try to access self->foo or self->_foo ?
Niether. The idea of the property is to use the accessors instead of direct access to the variable. You should use self.foo
to get and set the property (or [self foo]
and [self setFoo:newFoo];
if you dislike the dot-syntax). Also note that you don't have to explicitly synthesize the property.