cocoa - How do i get the information from the observationInfo method in Objective C KVO? -


there observationinfo method returns information of bindings of object. have looked around not know how information dictionary. can 1 lead me in right direction please?

edit in case 1 misunderstand im saying. classes kvo compliant. after add observer something object, self.something have binding information. if did [self.something observationinfo], returns dictionary. access contents of dictionary.

apple docs said

for improved performance, method , setobservationinfo: can overridden store opaque data pointer in instance variable. overrides of method must not attempt send objective-c messages stored data, including retain , release.

so know can done.. question how? see no info on line.

i suspect you're misunderstanding purpose of -observationinfo/-setobservationinfo:. value set , gotten methods opaque you. put differently, contents private system frameworks , you're not intended able access/parse it. comment docs excerpted was:

for improved performance, method , setobservationinfo: can overridden store opaque data pointer in instance variable. overrides of method must not attempt send objective-c messages stored data, including retain , release.

let me try clarify saying bit:

for every observation, frameworks need keep track of private data observation in order deliver later. how stores information not documented, conceptually, it's stored in map key pointer value of object , value opaque data structure.

in specific, performance-sensitive situations, may looking observation info in shared map impacts performance (i've never seen turn on profiling trace myself, that's not couldn't happen). in cases, better store pointer directly instance variable in object, changes fetch operation map-lookup simple add. system frameworks perspective, bet map-lookup cost usually far less onerous (in big picture) alternative, put instance variable in nsobject purpose (which make every object 8 bytes bigger whether uses kvo or not -- seems no-brainer.)

-observationinfo/-setobservationinfo: exist allow make optimization. if implemented optimization, these methods way know if object being observed or not (i.e. info value nil?) may allow make other changes object's behavior.

if have need keep list of observing objects , details they're observing other purpose, need overriding addobserver:... , removeobserver:..., , adding code maintain own data private structures (while still calling super.)


Comments