Skip to content

Instantly share code, notes, and snippets.

@tingham
Created May 21, 2010 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tingham/408413 to your computer and use it in GitHub Desktop.
Save tingham/408413 to your computer and use it in GitHub Desktop.
/*
* AppController.j
* AccTest
*
* Created by Thomas Ingham on May 17, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPDictionary myDictionary;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
myDictionary = [[CPDictionary alloc] init];
[myDictionary addObserver:self
forKeyPath:@"aKey"
options:CPKeyValueObservingOptionNew
context:nil];
[myDictionary setValue:@"Bob Jones" forKey:@"aKey"];
[myDictionary setValue:@"Jo Bob Ray" forKey:@"aKey"];
[CPTimer scheduledTimerWithTimeInterval:3
target:self
selector:@selector(modValue)
userInfo:nil
repeats:NO];
[theWindow orderFront:self];
// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
}
- (void)modValue {
CPLog(@"changing the value in the key.");
[myDictionary setValue:@"Alpha Beta Boo" forKey:@"aKey"];
}
- (void)observeValueForKeyPath:(CPString *)keyPath
ofObject:(id)object
change:(CPDictionary *)change
context:(void)context {
CPLog(@"observed value change");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment