Skip navigation.
 
mlRe: With What does Apple Swizzle the IsA-pointer in KVO?
FROM : Sherm Pendley
DATE : Fri Nov 23 19:09:53 2007

On Nov 23, 2007, at 11:50 AM, Paul Sargent wrote:

>> KVO is not based on the internals of an object (which is assumed 
>> to be hidden), and it does not access hiddden internals. KVO is 
>> based on KVC and uses accessors.
>>

> To expand a bit, my mental model of it is (and this could be wrong):
>
> No Observing:
>
> ObjA ----setBlah:----> ObjB
>
> Observing:
>
> ObjA ----setBlah:----> ProxyForB -----setBlah:----> ObjB
>                            |
>                            |
>                            \-------blahChanged:---> Observer
>
> i.e. When the observer registers a proxy is inserted in the chain. 
> The message is intercepted by the proxy and it notifies the Observer.


Isa-swizzling does not involve a proxy object - it changes the class 
of ObjB directly by manipulating its isa ivar, hence the name.

When you observe an object, a new subclass is created that inherits 
from that object's class, and overrides its KVC methods with versions 
that send -willChangeValueForKey: and -didChangeValueForKey: to any 
observers before and after calling the original class' KVC methods. 
The observed object's class is then changed by storing a pointer to 
the subclass in its isa ivar.

sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Related mailsAuthorDate
mlWith What does Apple Swizzle the IsA-pointer in KVO? Philip Mötteli Nov 23, 14:42
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Jean-Daniel Dupas Nov 23, 14:56
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Clark Cox Nov 23, 15:54
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Philip Mötteli Nov 23, 17:03
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Jean-Daniel Dupas Nov 23, 17:23
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Paul Sargent Nov 23, 17:50
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Clark Cox Nov 23, 18:05
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Philip Mötteli Nov 23, 19:09
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Philip Mötteli Nov 23, 19:09
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Sherm Pendley Nov 23, 19:09
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? mmalc crawford Nov 23, 19:25
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? glenn andreas Nov 23, 19:29
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Philip Mötteli Nov 23, 19:33
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Sherm Pendley Nov 23, 20:01
mlRe: With What does Apple Swizzle the IsA-pointer in KVO? Clark Cox Nov 23, 20:26