Instance variable naming


The book says that instance variables are named with a preceding underscore. Throughout the book I have noticed that when using properties the instance variables are sometimes written as _propertyName and also self.propertyName. An example is page 221, in initPrivate dictionary is _dictionary but in the rest of the methods such as setImage:forKey: it is written as self.dictionary. Is this preferences or is there a reason for this?


When you write _ivarName you access and change the instance variable directly.
With self.ivarName you use the setter methods that @property creates for you , or the ones you made custom.