Skip to content
Browse files

Small revisions / clean Up.

  • Loading branch information...
1 parent 4ae2d5c commit 7180b45191646c7f1dcb9e06f41dfb9816e00c0c @mralexgray mralexgray committed Dec 2, 2012
View
5 Examples/MacHRAutoTodoList/AppDelegate.h
@@ -9,11 +9,6 @@
#import "Todos.h"
-@interface TodoColorCell : NSActionCell
-@end
-@interface TodoPriorityClickCell : NSActionCell
-@end
-
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (weak) IBOutlet NSTableView *table;
View
21 Examples/MacHRAutoTodoList/AppDelegate.m
@@ -8,6 +8,10 @@
#import "AppDelegate.h"
+@interface TodoColorCell : NSActionCell
+@end
+@interface TodoPriorityClickCell : NSActionCell
+@end
@implementation AppDelegate
@@ -29,8 +33,8 @@ - (IBAction) loadFromPlist: (id)s
-(void)awakeFromNib
{
- ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Status"]]).dataCell = [TodoColorCell new];
- ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Priority"]]).dataCell = [TodoPriorityClickCell new];
+ ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Status"]]).dataCell = TodoColorCell.new;
+ ((NSTableColumn*)_table.tableColumns[[_table columnWithIdentifier: @"Priority"]]).dataCell = TodoPriorityClickCell.new;
}
@end
@@ -41,20 +45,21 @@ @implementation TodoPriorityClickCell
- (id) target { return self; }
-- (SEL) action { return @selector(tickPriority); }
+- (SEL) action { return @selector( tickPriority ); }
- (void) tickPriority
{
- NSUInteger val = [[self objectValue]unsignedIntegerValue];
- ((TodoItem*)[TodoList sharedInstance].items[[(NSTableView*)[self controlView]selectedRow]]).priority = @( val < 8 ? val + 1 : 0 );
+ NSUInteger val = [self.objectValue unsignedIntegerValue];
+ ((TodoItem*)TodoList.sharedInstance.items[((NSTableView*)self.controlView).selectedRow]).priority = @( val < 8 ? val + 1 : 0 );
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
- [[NSColor darkGrayColor]set]; NSRectFill(cellFrame);
+ [NSColor.darkGrayColor set];
+ NSRectFill ( cellFrame );
NSString *string = ((NSNumber*)self.objectValue).stringValue;
- NSDictionary *attrs = @{ NSFontAttributeName : [NSFont fontWithName:@"Lucida Grande Bold" size: cellFrame.size.height - 10], NSForegroundColorAttributeName : [NSColor whiteColor] };
- NSSize stringSize = [string sizeWithAttributes:attrs];
+ NSDictionary *attrs = @{ NSFontAttributeName : [NSFont fontWithName:@"Lucida Grande Bold" size: cellFrame.size.height - 10], NSForegroundColorAttributeName : NSColor.whiteColor };
+ NSSize stringSize = [string sizeWithAttributes:attrs];
[string drawInRect: (NSRect) { NSMidX(cellFrame) - stringSize.width / 2, cellFrame.origin.y + 3, stringSize.width, stringSize.height } withAttributes:attrs];
}
View
6 Examples/MacHRAutoTodoList/TodoList.m
@@ -15,11 +15,11 @@ @implementation TodoList
- (TodoItem*) newTodo
{
- TodoItem *newOne = [TodoItem instance];
- [self insertObject:newOne inItemsAtIndex:self.items.count];
+ TodoItem *newOne = TodoItem.instance;
+ [self insertObject:newOne inItemsAtIndex:self.items.count]; // KVO Array insertion trigger.
return newOne;
}
-- (TodoItem*) copyTodo:(TodoItem*)todo;
+- (TodoItem*) copyTodo: (TodoItem*)todo;
{
TodoItem *newOne = todo.copy;
[self insertObject:newOne inItemsAtIndex:self.items.count];
View
22 Examples/MacHRAutoTodoList/Todos.h
@@ -9,27 +9,25 @@
@interface TodoItem : BaseModel
-@property (nonatomic, strong) NSString *label;
-@property (nonatomic, assign) BOOL checked;
-@property (nonatomic, strong) NSNumber *priority;
+@property (readonly) NSColor *color;
+@property (nonatomic, strong) NSString *label;
+@property (nonatomic, strong) NSNumber *priority;
+@property (nonatomic) BOOL checked;
-@property (readonly) NSColor *color;
@end
@interface TodoList : BaseModel
-@property (nonatomic, retain) NSMutableArray *items;
+@property (nonatomic, strong) NSMutableArray *items;
- (TodoItem*) newTodo;
-- (TodoItem*) copyTodo:(TodoItem*)todo;
-
+- (TodoItem*) copyTodo: (TodoItem*)todo;
// Subclass specific KVO Compliant "items" accessors to trigger NSArrayController updates on inserts / removals.
-
+- (NSUInteger) countOfItems;
- (id) objectInItemsAtIndex: (NSUInteger) index;
- (void) removeObjectFromItemsAtIndex: (NSUInteger) index;
-- (void) insertObject: (TodoItem*) todo inItemsAtIndex:(NSUInteger)index;
-- (NSUInteger) countOfItems;
+- (void) insertObject: (TodoItem*) todo
+ inItemsAtIndex: (NSUInteger) index;
-
-@end
+@end

0 comments on commit 7180b45

Please sign in to comment.
Something went wrong with that request. Please try again.