Skip to content

Instantly share code, notes, and snippets.

@bdittmer
Created June 20, 2011 23:39
Show Gist options
  • Save bdittmer/1036882 to your computer and use it in GitHub Desktop.
Save bdittmer/1036882 to your computer and use it in GitHub Desktop.
@import <AppKit/AppKit.j>
@implementation WVNavigationViewController : CPViewController {
@outlet CPTableView navTableView;
@outlet CPView navItemView;
}
- (void)viewDidLoad {
[super viewDidLoad];
CPLog(@"navItemView = " + navItemView);
[[[navTableView tableColumns] objectAtIndex:0] setDataView:navItemView];
}
- (int)numberOfRowsInTableView:(CPTableView)aTableView {
return 2;
}
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(int)aColumn row:(int)aRow {
CPLog("tableView:objectValueForTableColumn");
if(aRow == 0) return { "name":"Welcome!" }; else return { "name":"User Insight" };
}
@end
@implementation WVNavItem : CPView {
@outlet CPImageView imageView;
@outlet CPTextField textField;
}
- (void)awakeFromCib {
CPLog(@"awake from cib " + textField);
}
- (void)setObjectValue:(Object)object {
CPLog("setObjectValue: " + object.name + ", self = " + self);
[textField setStringValue:object.name];
CPLog("textfield: " + textField);
}
- (id)initWithCoder(CPCoder)aCoder {
self = [super initWithCoder:aCoder];
imageView = [aCoder decodeObjectForKey:@"imageView"];
textField = [aCoder decodeObjectForKey:@"textField"];
CPLog("initWithCoder being called: " + textField);
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder {
CPLog("encoder: " + textField);
[super encodeWithCoder:aCoder];
[aCoder encodeObject:imageView forKey:@"imageView"];
[aCoder encodeObject:textField forKey:@"textField"];
}
@end
OUTPUT:
2011-06-20 16:38:41.333 Cappuccino [info]: awake from cib <CPTextField 0x00518f>
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.335 Cappuccino [info]: navItemView = <WVNavItem 0x0051c1>
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.335 Cappuccino [info]: encoder: <CPTextField 0x00518f>
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.374 Cappuccino [info]: tableView:objectValueForTableColumn
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.374 Cappuccino [info]: setObjectValue: Welcome!, self = <WVNavItem 0x005427>
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.374 Cappuccino [info]: textfield: null
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.377 Cappuccino [info]: tableView:objectValueForTableColumn
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.377 Cappuccino [info]: setObjectValue: User Insight, self = <WVNavItem 0x00548b>
Frameworks/Debug/Objective-J/Objective-J.js:4322011-06-20 16:38:41.377 Cappuccino [info]: textfield: null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment