Skip to content

Commit

Permalink
added NSTableView_setObjectValue sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunagan committed Apr 25, 2009
1 parent eb90c46 commit 302284a
Show file tree
Hide file tree
Showing 10 changed files with 3,901 additions and 0 deletions.
21 changes: 21 additions & 0 deletions NSTableView_setObjectValue/BDObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// BDObject.h
// NSTableView_setObjectValue
//
// Created by Brian Dunagan on 4/24/09.
// Copyright 2009 bdunagan.com. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface BDObject : NSObject {
BOOL isChecked;
}

- (id)init;
- (BOOL)isChecked;
- (void)setIsChecked:(BOOL)newValue;
- (NSString *)status;
- (void)setStatus:(id)value;

@end
38 changes: 38 additions & 0 deletions NSTableView_setObjectValue/BDObject.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// BDObject.m
// NSTableView_setObjectValue
//
// Created by Brian Dunagan on 4/24/09.
// Copyright 2009 bdunagan.com. All rights reserved.
//

#import "BDObject.h"

@implementation BDObject

- (id)init {
self = [super init];
if (self != nil) {
isChecked = NO;
}
return self;
}

- (BOOL)isChecked {
return isChecked;
}

- (void)setIsChecked:(BOOL)newValue {
isChecked = newValue;

// Update dependent property.
[self setStatus:nil];
}

- (NSString *)status {
return isChecked ? @"Checked" : @"Unchecked";
}

- (void)setStatus:(id)value {}

@end
Binary file not shown.
3,453 changes: 3,453 additions & 0 deletions NSTableView_setObjectValue/English.lproj/MainMenu.xib

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions NSTableView_setObjectValue/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions NSTableView_setObjectValue/MainController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// MainController.h
// NSTableView_setObjectValue
//
// Created by Brian Dunagan on 4/24/09.
// Copyright 2009 bdunagan.com. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface MainController : NSObject {
IBOutlet NSTableView *list;
IBOutlet NSArrayController *objects;
}

@end
36 changes: 36 additions & 0 deletions NSTableView_setObjectValue/MainController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// MainController.m
// NSTableView_setObjectValue
//
// Created by Brian Dunagan on 4/24/09.
// Copyright 2009 bdunagan.com. All rights reserved.
//

#import "MainController.h"
#import "BDObject.h"

@implementation MainController

- (void)awakeFromNib {
BDObject *object;

object = [[BDObject alloc] init];
[objects addObject:object];
[object release];

object = [[BDObject alloc] init];
[objects addObject:object];
[object release];
}

- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
if (aTableView == list) {
// Update dependent instances.
BOOL newValue = [[[objects arrangedObjects] objectAtIndex:rowIndex] isChecked];
for (BDObject *object in [objects arrangedObjects]) {
[object setIsChecked:newValue];
}
}
}

@end
Loading

0 comments on commit 302284a

Please sign in to comment.