What does @dynamic do in Objective-C?
39,887
@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.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on July 08, 2022Comments
-
Admin almost 2 years
Objective-C has a feature called @dynamic.
Google only lists results about dynamic typing.
I rarely see this in code and I don't understand what it is used for. Can anyone explain me this? Thanks.