Hello and thanks Richard. Although I don't need such heavy-weapons, and I don't at all deal with programmatic bindings here, I'd still like (if possible) to learn some more about the implementation of your internal tools. I didn't yet have a chance to work with swizzling, and maybe its time I started.
My case is not of complexity, but of performance. If I simply observe all the time, and then filter what I need, penalty would be too much. I get huge amount of observation-calls (every refresh of my core-data context) and I need to inspect lots On 9 בספט 2012, at 15:07, Richard Somers wrote: > On Sep 9, 2012, at 3:32 AM, Motti Shneor wrote: > >> - (NSUInteger)isObserver:(id)object on keyPath:(NSString *)keyPath >> withContext:(void *)context]; // the returned number is the count of same >> observances with 0 as not-observing). >> >> and something like >> >> - (BOOL)removeObserver:(id)object; // where I instruct the receiver to >> remove object as an observer, on all key-paths and contexts. should return >> YES if object was an observer, and was removed, NO otherwise. >> >> Any ideas? > > I recently did something similar only for bindings. > > @interface NSObject (MYBindings) > + (NSString *)my_objectsWithActiveBindings; // for debugging > + (NSUInteger)my_objectsWithActiveBindingsCount; // for debugging > - (void)my_revmoveAllBindings; > @end > > This was implemented by swizzling the NSObject implementation of > -bind:toObject:withKeyPath:options: and -unbind: at runtime using JRSwizzle > along with keeping binding information for each instance in a single static > mutable dictionary (associative storage pattern). The swizzled methods call > the NSObject implementation of -bind:... and -unbind: and also keep track of > the additional binding information needed. > > I am working on a project with a lot of programmatic bindings and I needed > some debugging aids and other routines to help with binding management. At > first I was hesitant to swizzle a framework method but I desperately needed > some help. So far it seems to be working well and the new routines helped > uncover a bug that I literally spent days trying to find with no success. > > --Richard > Motti Shneor e-mail: [email protected] phone: +972-8-9267730 mobile: +972-54-3136621 ---------------------------------------- Ceterum censeo Microsoftinem delendam esse _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
