Why do we need synthesize in IOS ?

@property declares an interface. It tells other modules that there will be a getter (and possibly a setter, if the property isn't readonly) method that uses a give data type, and follows certain memory management rules.

You can then either implement those getters and setters yourself, through custom code, or add a synthesize statement, which asks the compiler to create (synthesize) the getter and/or setter methods for you.

There's another statement, @dymamic, that tells the compiler not to generate getters and/or setters, because they will be provided at runtime. The most common use for @dynamic is Core Data.

Yorumlar

Popüler Yayınlar