Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does @dynamic do in Objective-C? [duplicate]

People also ask

What does @dynamic do in Objective C?

@dynamic just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass or will be provided at runtime).

What does @class mean in Objective C?

@class is used for creating forward declaration of any class. If you're creating any class that's implementation is unknown to you then you can do this using @class compiler directive. You can implement this class when the implementation is known to you.


@dynamic means “my class will figure out how to respond to this at runtime.” Uses a runtime mechanism for an object to intercept messages it normally wouldn’t respond to. In the case where a Core Data db is used to store persistent data, NSManagedObject turns these into calls to -valueForKey: and -setValueForKey:.

Take a look at Lecture 12 (Fall 2010) of Stanford's iPhone development course.