When do you have to use @property and @synthesize in the iPhone SDK? And why use @property and @synthesize?
I was studying property, but I can’t get a correct idea. What would some examples for illustrating this be?
When do you have to use @property and @synthesize in the iPhone SDK? And
Share
@property : you used it when you want to:
You can use some of the really useful generated code like nonatomic, atmoic, retain without writing any lines of code. You also have getter and setter methods. To use this, you have 2 other ways: @synthesize or @dynamic: @synthesize, compiler will generate the getter and setter automatically for you, @dynamic: you have to write them yourself.
@property is really good for memory management, for example: retain.
How can you do retain without @property?
How can you use it with @property?
When you are calling the above line, you actually call the setter like [self setVariable:object] and then the generated setter will do its job