What does @NSManaged do? What does @NSManaged do? ios ios

What does @NSManaged do?


Yes, it kinda really acts like @dynamic -- technically it might be identical even. Semantically there is a slight difference:

@dynamic says 'compiler, don't check if my properties are also implemented. There might be no code you can see but I guarantee it will work at runtime'

@NSManaged now says 'compiler, don't check those properties as I have Core Data to take care of the implementation - it will be there at runtime'

so you could even say: @NSManaged is syntactic sugar that is a more narrow version of dynamic :)


https://github.com/KyoheiG3/DynamicBlurView/issues/2
here someone even used @NSManaged without CD because he wanted the @dynamic behaviour


In the apple docs, for Custom Managed Object Class, they quote properties example like...enter image description hereTo me it seems there is no difference, I have used @dynamic in objective C, it seems @NSManaged is the replacement in Swift.


Above mentioned answers are right. Here is my understanding.

@NSManaged indicates that the variables will get some values when we run the app. Coredata automatically creates getter and setter for such props. It silences the compiler for warnings.

NSmanaged is subclass of NSObject. @NSManaged means extra code will be given to these props at runtime.It tracks the changes made to those properties.