Unheilig
Unheilig

Reputation: 16292

Key Value Coding clarification

From Apple's documentation I came across the following:

Setting values using key paths is not the same as setting them using Objective-C properties. You cannot use property notation to set transform values. You must use the setValue:forKeyPath: method with the preceding key path strings.

From my understanding, we must have properties of our ivars in order to use KVC.

But from the paragraph above, it seems to say otherwise:

Setting values using key paths is not the same as setting them using Objective-C properties. You cannot use property notation to set transform values.

Can someone explain to me why? Perhaps I am missing something, because all along my understanding is that we must have properties to utilize KVC.

Upvotes: 0

Views: 106

Answers (1)

Wain
Wain

Reputation: 119021

From my understanding, we must have properties of our ivars in order to use KVC.

This is incorrect. KVC will use the property generated accessor methods, or other (appropriately named) accessor methods if they exist, but they aren't required. If they don't exist KVC will attempt to directly access the instance variables.

Check this Apple ref for a description of how KVC searches for the key to update.

Upvotes: 1

Related Questions