For example, in the following codes.
@interface TUTViewController : UIViewController
{
NSTimer *timer;
}
@end
and
@interface TUTViewController : UIViewController
@property (weak, nonatomic) NSTimer *timer;
@end
In which scenario do we use the first method to declare variable?
I would highly suggest to use @properties unless there is a very good reason not to. It's true the discussion is a religious one more than a technical one but since we are probably all followers of the Cult of Mac, if Apple prefers you to use @properties then that's the standard. In my opinion both Apple documentation and Xcode aren't as pushy on standards like ReSharper would do in Visual Studio for instance (it warns when you don't use var for example). That's a pity because that would make it easier for me to pick up code after somebody else.
There is a way to "hide" @properties in a .m file, you should declare it as follows:
These are not completely private to another consumer of your class but it is hidden at first sight. This should tell the other developer that he or she should not use them. I think public/private has more to do with documentation as it has to do with application security for most apps.