KVUtils.h
author Jens Alfke <jens@mooseyard.com>
Wed Apr 02 14:45:33 2008 -0700 (2008-04-02)
changeset 2 3d3dcc3116d5
child 3 8fad19466c59
permissions -rw-r--r--
UniqueWindowController finds windows that are miniaturized.
Added some date and more graphics utilities.
jens@0
     1
//
jens@0
     2
//  KVUtils.h
jens@0
     3
//  MYUtilities
jens@0
     4
//
jens@0
     5
//  Created by Jens Alfke on 2/25/08.
jens@0
     6
//  Copyright 2008 Jens Alfke. All rights reserved.
jens@0
     7
//
jens@0
     8
jens@0
     9
#import <Cocoa/Cocoa.h>
jens@0
    10
jens@0
    11
jens@0
    12
enum {
jens@0
    13
    MYKeyValueObservingOptionOnce = 1<<31,
jens@0
    14
    MYKeyValueObservingOptionDelayed = 1<<30
jens@0
    15
};
jens@0
    16
jens@0
    17
jens@0
    18
jens@0
    19
@interface Observance : NSObject
jens@0
    20
{
jens@0
    21
    id _target;
jens@0
    22
    id _observed;
jens@0
    23
    NSString *_keyPath;
jens@0
    24
    NSKeyValueObservingOptions _options;
jens@0
    25
    SEL _action;
jens@0
    26
}
jens@0
    27
jens@0
    28
- (id) initWithTarget: (id)target 
jens@0
    29
               action: (SEL)action
jens@0
    30
             observed: (id)observed
jens@0
    31
              keyPath: (NSString*)keyPath 
jens@0
    32
              options: (NSKeyValueObservingOptions)options;
jens@0
    33
jens@0
    34
- (void) stopObserving;
jens@0
    35
jens@0
    36
@property (readonly) id observed;
jens@0
    37
@property (readonly) NSString* keyPath;
jens@0
    38
jens@0
    39
@end
jens@0
    40
jens@0
    41
jens@0
    42
jens@0
    43
@interface Observer : NSObject
jens@0
    44
{
jens@0
    45
    id _target;
jens@0
    46
    NSMutableArray *_observances;
jens@0
    47
}
jens@0
    48
jens@0
    49
- (id) initWithTarget: (id)target;
jens@0
    50
jens@0
    51
@property (readonly) id target;
jens@0
    52
jens@0
    53
- (void) observe: (id)observed 
jens@0
    54
         keyPath: (NSString*)keyPath 
jens@0
    55
         options: (NSKeyValueObservingOptions)options
jens@0
    56
          action: (SEL)action;
jens@0
    57
jens@0
    58
- (void) observe: (id)observed 
jens@0
    59
         keyPath: (NSString*)keyPath 
jens@0
    60
          action: (SEL)action;
jens@0
    61
jens@0
    62
- (void) stopObserving: (id)observedOrNil keyPath: (NSString*)keyPathOrNil;
jens@0
    63
jens@0
    64
- (void) stopObserving;
jens@0
    65
jens@0
    66
@end