Skip to content

Instantly share code, notes, and snippets.

@hugithordarson
Created December 3, 2010 10:48
Show Gist options
  • Save hugithordarson/726821 to your computer and use it in GitHub Desktop.
Save hugithordarson/726821 to your computer and use it in GitHub Desktop.
#import "Controller.h"
@implementation Controller
- (IBAction)fetch:(id)sender {
NSMutableArray *fetchedItems = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://hugi.karlmenn.is/d/plist.plist" ]];
items = fetchedItems;
for( NSDictionary *d in items ) {
for( NSString *key in [ d allKeys ] ) {
NSTableColumn *column = [table tableColumnWithIdentifier:key ];
if( !column ) {
column = [[ NSTableColumn alloc ] initWithIdentifier:key ];
[ [ column headerCell ] setStringValue:key ];
[ table addTableColumn:column ];
}
}
}
[ table reloadData ];
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView {
return [ items count ];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row {
return [[ items objectAtIndex:row ] valueForKey:[ tableColumn identifier ] ];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment