When synthesizing properties in Objective-C, it’s recommended that you dont simply write:
@synthesize window;
but rather
@synthesize window = _window;
The reasoning is that you don’t want your instance variable named the same as your getter method or “bad things can happen”.
I’ve always used @synthesize var1, var2, etc in my apps without “bad things” happening. What sort of bad things could happen?
Bad things used to happen, particularly in the pre-ARC days when people would assign objects to the storage iVar instead of the property. If this was done by accident, then the memory management implied by the synthesized setter wouldn’t be applied, leading to leaks, or premature releases.
I use to do it the simple way, but now I use prefixes. I don’t declare my iVar themselves anymore, I let the modern runtime take care of that for me. I use prefixes so that I don’t accidentally use an iVar like a local variable.
Also – I tend to refer to my properties as
self.iVaralmost everywhere in my classes. This is so that I can use lazy loaded properties when I want to without worrying about which ones are and are not lazily loaded.