What does @dynamic do in Objective-C?

Objective CDynamic

Objective C Problem Overview


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.

Objective C Solutions


Solution 1 - Objective C

@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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser142019View Question on Stackoverflow
Solution 1 - Objective CPenangView Answer on Stackoverflow