DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | Class Methods | List of all members
GCObservableObject Class Reference

This is used to permit setting up KVO in a simpler manner than comes as standard. More...

Inheritance diagram for GCObservableObject:
Inheritance graph
[legend]

Instance Methods

(NSString *) - actionNameForKeyPath:
 
(NSString *) - actionNameForKeyPath:changeKind:
 
(NSArray *) - oldArrayValueForKeyPath:
 
(void) - registerActionNames
 
(void) - sendInitialValuesForAllPropertiesToObserver:context:
 
(void) - setActionName:forKeyPath:
 
(BOOL- setUpKVOForObserver:
 
(void) - setUpObservables:forObserver:
 
(BOOL- tearDownKVOForObserver:
 
(void) - tearDownObservables:forObserver:
 
- Instance Methods inherited from NSObject
(NSString *) - address
 
(DKStyleRegistry *) - applicationWillReturnStyleRegistry
 
(BOOL- canBeUsedWithSelectionTool
 
(id- categoryManager:shouldReplaceObject:withObject:
 
(Class- classForCoder
 
(NSColor *) - colorValue
 
(NSColor *) - colourValue
 
(id- copy
 
(void) - dealloc
 
(id- deepCopy
 
(NSDictionary *) - dimensionValuesForArrowStroke:
 
(CGFloat- drawing:convertDistanceToExternalCoordinates:
 
(NSPoint) - drawing:convertLocationToExternalCoordinates:
 
(void) - drawing:didDrawRect:inView:
 
(void) - drawing:willDrawRect:inView:
 
(NSString *) - drawing:willReturnAbbreviationForUnit:
 
(NSString *) - drawing:willReturnFormattedCoordinateForDistance:
 
(CGFloat- drawingWillReturnUnitToPointsConversonFactor:
 
(void) - finalize
 
(NSString *) - hexString
 
(void) - hotspot:didEndTrackingWithEvent:inView:
 
(void) - hotspot:isTrackingWithEvent:inView:
 
(void) - hotspot:willBeginTrackingWithEvent:inView:
 
(NSData *) - imageData
 
(NSImage *) - imageResourceNamed:
 
(id- init
 
(id- initWithExpression:
 
(id- instantiateObjectWithShortName:parameters:
 
(BOOL- isLiteralValue
 
(void) - layoutManager:willPlaceGlyphAtIndex:atLocation:pathAngle:yOffset:
 
(void) - menuItem:wasAddedForObject:inCategory:
 
(BOOL- moveObjectTo:position:slope:userInfo:
 
(id- mutableCopy
 
(void) - oneShotComplete
 
(void) - oneShotHasReached:
 
(void) - oneShotWillBegin
 
(void) - path:elementIndex:type:points:subPathIndex:subPathClosed:contextInfo:
 
(id- placeLinkFromPoint:toPoint:onPath:linkNumber:userInfo:
 
(id- placeObjectAtPoint:onPath:position:slope:userInfo:
 
(NSPoint) - point
 
(NSPoint) - pointForTextLayout
 
(DKStyle *) - registry:shouldReplaceStyle:withStyle:
 
(NSBezierPath *) - renderer:willRenderPath:
 
(void) - routeFinder:progressHasReached:
 
(void) - setValue:forNumericParameter:
 
(NSString *) - stringValue
 
(CGFloat- taperFactorAtDistance:onPath:ofLength:
 
(void) - toolDidPerformUndoableAction:
 
(void) - toolWillPerformUndoableAction:
 
(NSURL *) - url
 
- Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Instance Methods inherited from <NSKeyValueBindingCreation>
(void) - bind:toObject:withKeyPath:options:
 
(NSArray *) - exposedBindings
 
(NSDictionary *) - infoForBinding:
 
(NSArray *) - optionDescriptionsForBinding:
 
(void) - unbind:
 
(Class- valueClassForBinding:
 

Class Methods

(NSString *) + actionNameForKeyPath:objClass:
 
(NSArray *) + observableKeyPaths
 
(void) + registerActionName:forKeyPath:objClass:
 
- Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Class Methods inherited from <NSKeyValueBindingCreation>
(void) + exposeBinding:
 

Detailed Description

This is used to permit setting up KVO in a simpler manner than comes as standard.

Author
Contributions from the community; see CONTRIBUTORS.md
Date
2005-2015

This is used to permit setting up KVO in a simpler manner than comes as standard.

The idea is that each class simply publishes a list of the observable properties that an observer can observe. When the observer wants to start observing all of these published properties, it calls setUpKVOForObserver: conversely, tearDownKVOForObserver: will stop the observer watching all the published properties.

Subclasses can also override these methods to be more selective about which properties are observed, or to propagate the message to additional observable objects they own.

This class also works around a bug or oversight in the KVO implementation (in 10.4 at least). When an array is changed, the old value isn't sent to the observer. To allow this, we record the old value locally. An observer can then call us back to get this old array if it needs to (for example, when building an Undo invocation).

The undo relay class provides a standard implementation for using KVO to implement Undo when using GCObservables. The relay needs to be added as an observer to any observable and given an undo manager. Then it will relay undoable actions from the observed objects to the undo manager and vice versa, implementing undo for all keypaths declared by the observee.

Method Documentation

- (NSString*) actionNameForKeyPath: (NSString *)  keypath
- (NSString*) actionNameForKeyPath: (NSString *)  keypath
changeKind: (NSKeyValueChange)  kind 
+ (NSString*) actionNameForKeyPath: (NSString *)  kp
objClass: (Class cl 
+ (NSArray*) observableKeyPaths
- (NSArray*) oldArrayValueForKeyPath: (NSString *)  keypath
+ (void) registerActionName: (NSString *)  na
forKeyPath: (NSString *)  kp
objClass: (Class cl 
- (void) registerActionNames
- (void) sendInitialValuesForAllPropertiesToObserver: (id object
context: (void *)  context 
- (void) setActionName: (NSString *)  name
forKeyPath: (NSString *)  keypath 
- (BOOL) setUpKVOForObserver: (id object
- (void) setUpObservables: (NSArray *)  keypaths
forObserver: (id object 
- (BOOL) tearDownKVOForObserver: (id object
- (void) tearDownObservables: (NSArray *)  keypaths
forObserver: (id object