-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
182 changed files
with
6,780 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// CNFAddNewCurrencyWindowController.h | ||
// CoinNotify | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface CNFAddNewCurrencyWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate> | ||
|
||
@property (strong) NSMutableArray *options; | ||
@property (assign) IBOutlet NSTableView *resultsTableView; | ||
|
||
- (IBAction)addCurrency:(id)sender; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// CNFAddNewCurrencyWindowController.m | ||
// CoinNotify | ||
// | ||
|
||
#import "CNFAddNewCurrencyWindowController.h" | ||
#import "CNFExchangeItemEntity.h" | ||
#import "CNFExchangesDataSource.h" | ||
|
||
@implementation CNFAddNewCurrencyWindowController | ||
|
||
- (id)initWithWindow:(NSWindow *)window | ||
{ | ||
self = [super initWithWindow:window]; | ||
if (self) { | ||
NSURL *currenciesURL = [[NSBundle mainBundle] URLForResource:@"currencies" withExtension:@"plist"]; | ||
_options = [[NSMutableArray alloc] initWithContentsOfURL:currenciesURL]; | ||
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"symbol" ascending:YES]; | ||
[_options sortUsingDescriptors:[NSArray arrayWithObject:sort]]; | ||
|
||
NSLog(@"Options count %ld", (unsigned long)_options.count); | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)windowDidLoad | ||
{ | ||
[super windowDidLoad]; | ||
[[self window] makeKeyAndOrderFront:nil]; | ||
[_resultsTableView reloadData]; | ||
} | ||
|
||
- (IBAction)addCurrency:(id)sender | ||
{ | ||
NSInteger row = [_resultsTableView selectedRow]; | ||
if (row == -1) { | ||
return; | ||
} | ||
|
||
[[CNFExchangesDataSource sharedDatasource] addEntity:[CNFExchangeItemEntity fromDictionary:[_options objectAtIndex:row]]]; | ||
[[CNFExchangesDataSource sharedDatasource] updateQuotes]; | ||
} | ||
|
||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView | ||
{ | ||
return [_options count]; | ||
} | ||
|
||
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row | ||
{ | ||
NSTextField *result = [[NSTextField alloc] init]; | ||
[result setBordered:NO]; | ||
[result setBackgroundColor:[NSColor colorWithCalibratedWhite:1 alpha:0]]; | ||
[result setEditable:NO]; | ||
|
||
if ([tableColumn.identifier isEqual: @"symbol"]) { | ||
result.stringValue = [(NSDictionary*)[_options objectAtIndex:row] objectForKey:@"symbol"]; | ||
} else if ([tableColumn.identifier isEqual: @"exchange"]) { | ||
result.stringValue = [(NSDictionary*)[_options objectAtIndex:row] objectForKey:@"exchange"]; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
@end |
Oops, something went wrong.