KVUtils.h
author snej@snej-mbp.mtv.corp.google.com
Wed Apr 08 16:31:19 2009 -0700 (2009-04-08)
changeset 24 629c7605ab2a
parent 0 d84d25d6cdbb
permissions -rw-r--r--
Changes to config-file structure.
     1 //
     2 //  KVUtils.h
     3 //  MYUtilities
     4 //
     5 //  Created by Jens Alfke on 2/25/08.
     6 //  Copyright 2008 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import <Cocoa/Cocoa.h>
    10 
    11 
    12 enum {
    13     MYKeyValueObservingOptionOnce = 1<<31,
    14     MYKeyValueObservingOptionDelayed = 1<<30
    15 };
    16 
    17 
    18 
    19 @interface Observance : NSObject
    20 {
    21     id _target;
    22     id _observed;
    23     NSString *_keyPath;
    24     NSKeyValueObservingOptions _options;
    25     SEL _action;
    26 }
    27 
    28 - (id) initWithTarget: (id)target 
    29                action: (SEL)action
    30              observed: (id)observed
    31               keyPath: (NSString*)keyPath 
    32               options: (NSKeyValueObservingOptions)options;
    33 
    34 - (void) stopObserving;
    35 
    36 @property (readonly) id observed;
    37 @property (readonly) NSString* keyPath;
    38 
    39 @end
    40 
    41 
    42 
    43 @interface Observer : NSObject
    44 {
    45     id _target;
    46     NSMutableArray *_observances;
    47 }
    48 
    49 - (id) initWithTarget: (id)target;
    50 
    51 @property (readonly) id target;
    52 
    53 - (void) observe: (id)observed 
    54          keyPath: (NSString*)keyPath 
    55          options: (NSKeyValueObservingOptions)options
    56           action: (SEL)action;
    57 
    58 - (void) observe: (id)observed 
    59          keyPath: (NSString*)keyPath 
    60           action: (SEL)action;
    61 
    62 /** observed or keyPath may be nil, meaning wildcard */
    63 - (void) stopObserving: (id)observedOrNil keyPath: (NSString*)keyPathOrNil;
    64 - (void) stopObserving: (id)observed;
    65 - (void) stopObserving;
    66 
    67 @end