// // NSObject+ProcObservation.h // Version 1.0 // // Andy Matuschak // andy@andymatuschak.org // Public domain because I love you. Let me know how you use it. // // NTW 2009-Oct-21: Added selectors with an options argument. // NTW 2009-Oct-30: Transplanted new observation key from MYUtilities's KVUtils. // NTW 2010-Jan-06: Changed to accept Ruby proc instead of C block. Got rid of block token typedef so MacRuby isn't confused. See NSObject_ProcObservation.rb for handy Ruby interface. #import // Or MYKeyValueObservingOptionOnce with your observation options to cause the // observer to remove itself upon the first change notification. // Idea and line of code from MYUtilities. enum { MYKeyValueObservingOptionOnce = 1<<31 }; @interface NSObject (AMRubyBlockObservation) - (NSString *)addObserverForKeyPath:(NSString *)keyPath proc:(id)proc; - (NSString*)addObserverForKeyPath:(NSString*)keyPath options:(NSKeyValueObservingOptions)options proc:(id)proc; - (NSString*)addObserverForKeyPath:(NSString*)keyPath onQueue:(NSOperationQueue*)queue proc:(id)proc; - (NSString*)addObserverForKeyPath:(NSString*)keyPath options:(NSKeyValueObservingOptions)options onQueue:(NSOperationQueue*)queue proc:(id)proc; - (void)removeObserverWithProcToken:(NSString *)token; @end