Split view management out of NJDeviceController. Right now this probably just makes...
[enjoyable.git] / Categories / NSOutlineView+ItemAccessors.m
diff --git a/Categories/NSOutlineView+ItemAccessors.m b/Categories/NSOutlineView+ItemAccessors.m
new file mode 100644 (file)
index 0000000..8f1a9be
--- /dev/null
@@ -0,0 +1,27 @@
+//
+//  NSOutlineView+ItemAccessors.m
+//  Enjoyable
+//
+//  Created by Joe Wreschnig on 3/16/13.
+//
+//
+
+#import "NSOutlineView+ItemAccessors.h"
+
+@implementation NSOutlineView (ItemAccessors)
+
+- (void)selectItem:(id)item {
+    NSInteger row = [self rowForItem:item];
+    if (row >= 0) {
+        [self selectRowIndexes:[[NSIndexSet alloc] initWithIndex:row]
+          byExtendingSelection:NO];
+    } else {
+        [self deselectAll:nil];
+    }
+}
+
+- (id)selectedItem {
+    return self.selectedRow >= 0 ? [self itemAtRow:self.selectedRow] : nil;
+}
+
+@end