Skip to content

Commit

Permalink
Initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ibittler committed Aug 15, 2013
1 parent e3e1e1e commit 5f19cfb
Show file tree
Hide file tree
Showing 182 changed files with 6,780 additions and 0 deletions.
475 changes: 475 additions & 0 deletions CoinNotify.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions CoinNotify/CNFAddNewCurrencyWindowController.h
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
66 changes: 66 additions & 0 deletions CoinNotify/CNFAddNewCurrencyWindowController.m
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
Loading

0 comments on commit 5f19cfb

Please sign in to comment.