I\'m rather confused about properties and instance variables in Objective-C.
I\'m about half-way through Aaron Hillegass\'s \"Cocoa Programming for Mac OS X\" and ev
However, in the iPhone world, things seem to be different. People declare properties for every single instance variable, declare properties for
IBOutlets, and use accessors/mutators to interact with instance variables within the class (e.g. they would write[self setName:@"Test"]rather thanname = @"Test").
That's not iPhone-specific. Except in init methods and the dealloc method, it's good practice to always use your accessors. The main benefit, especially on the Mac (with Cocoa Bindings), is that using your accessors means free KVO notifications.
The reason why people “declare properties for every single instance variable” is most probably that all of their instance variables are things they want to expose as properties. If they had something they would want to keep private, they would not declare a property for it in the header file. (However, they may make a property for it in a class extension in the implementation file, in order to get the aforementioned free KVO notifications.)
Declaring properties for outlets is overkill, in my opinion. I don't see a point to it. If you don't make a property, the nib loader will set the outlet by direct instance-variable access, which is just fine for that task.