1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/KVUtils.h Wed Apr 02 14:45:33 2008 -0700
1.3 @@ -0,0 +1,66 @@
1.4 +//
1.5 +// KVUtils.h
1.6 +// MYUtilities
1.7 +//
1.8 +// Created by Jens Alfke on 2/25/08.
1.9 +// Copyright 2008 Jens Alfke. All rights reserved.
1.10 +//
1.11 +
1.12 +#import <Cocoa/Cocoa.h>
1.13 +
1.14 +
1.15 +enum {
1.16 + MYKeyValueObservingOptionOnce = 1<<31,
1.17 + MYKeyValueObservingOptionDelayed = 1<<30
1.18 +};
1.19 +
1.20 +
1.21 +
1.22 +@interface Observance : NSObject
1.23 +{
1.24 + id _target;
1.25 + id _observed;
1.26 + NSString *_keyPath;
1.27 + NSKeyValueObservingOptions _options;
1.28 + SEL _action;
1.29 +}
1.30 +
1.31 +- (id) initWithTarget: (id)target
1.32 + action: (SEL)action
1.33 + observed: (id)observed
1.34 + keyPath: (NSString*)keyPath
1.35 + options: (NSKeyValueObservingOptions)options;
1.36 +
1.37 +- (void) stopObserving;
1.38 +
1.39 +@property (readonly) id observed;
1.40 +@property (readonly) NSString* keyPath;
1.41 +
1.42 +@end
1.43 +
1.44 +
1.45 +
1.46 +@interface Observer : NSObject
1.47 +{
1.48 + id _target;
1.49 + NSMutableArray *_observances;
1.50 +}
1.51 +
1.52 +- (id) initWithTarget: (id)target;
1.53 +
1.54 +@property (readonly) id target;
1.55 +
1.56 +- (void) observe: (id)observed
1.57 + keyPath: (NSString*)keyPath
1.58 + options: (NSKeyValueObservingOptions)options
1.59 + action: (SEL)action;
1.60 +
1.61 +- (void) observe: (id)observed
1.62 + keyPath: (NSString*)keyPath
1.63 + action: (SEL)action;
1.64 +
1.65 +- (void) stopObserving: (id)observedOrNil keyPath: (NSString*)keyPathOrNil;
1.66 +
1.67 +- (void) stopObserving;
1.68 +
1.69 +@end