Reputation: 49354
So far I have seen only CoreData using @dynamic
property accessor definitions. What other ways are there for a property to get dynamic accessors in Cocoa object so that they can be marked as @dynamic
?
Upvotes: 1
Views: 641
Reputation: 14558
You can generate an accessor at runtime by responding to +resolveInstanceMethod:
(which is what Core Data does) or simulate it with -forwardInvocation:
. I’ve seen this used in mock model objects which support arbitrary (object-valued) properties, although in that case properties were declared in unimplemented categories so no explicit @dynamic
was used. (Actually, I’ve written a stupid hack that makes NSDictionary
behave this way.)
I could imagine a similar approach being used for a proxy object.
Upvotes: 1
Reputation: 15442
You can declare a property dynamic yourself. This may be useful if, for example, the getter and setter methods are implemented by your superclass.
Upvotes: 0
Reputation: 6413
By default, all declared properties are @dynamic, however you can declare them as @synthesize. @dynamic means, that you will provide getter and setter implementation in your class, that may be linked to no any i-var.
Upvotes: 0