add table view data source
parent
cc1256d99c
commit
1515a0d950
@ -1,5 +1,5 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "EventListener.h"
|
||||
|
||||
@interface MainViewController : NSViewController <EventListener>
|
||||
@interface MainViewController : NSViewController <EventListener, NSTableViewDataSource>
|
||||
@end
|
||||
|
@ -0,0 +1,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "ui_darwin.h"
|
||||
|
||||
@interface RequestHistory : NSObject <NSTableViewDataSource>
|
||||
- (void) addRequestItem:(RequestMeta *)meta;
|
||||
- (void) addResponseItem:(ResponseMeta *)meta;
|
||||
@end
|
@ -0,0 +1,35 @@
|
||||
#import "RequestHistory.h"
|
||||
|
||||
@interface RequestHistory ()
|
||||
@property (strong) NSMutableArray *items;
|
||||
@end
|
||||
|
||||
@implementation RequestHistory
|
||||
|
||||
- (instancetype) init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self setItems:[[NSMutableArray alloc] initWithCapacity:1000]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger) numberOfRowsInTableView:(NSTableView *)view {
|
||||
return [[self items] count];
|
||||
}
|
||||
|
||||
- (id) tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger) row {
|
||||
NSLog(@"[RequestHistory] objectValueForTableColumn: %@ row: %zd", column, row);
|
||||
return [[self items] objectAtIndex:row];
|
||||
}
|
||||
|
||||
- (void) addRequestItem:(RequestMeta *)meta {
|
||||
NSLog(@"[RequestHistory] add request item");
|
||||
[[self items] addObject:[NSValue valueWithBytes:meta objCType:@encode(RequestMeta)]];
|
||||
}
|
||||
|
||||
- (void) addResponseItem:(ResponseMeta *)meta {
|
||||
NSLog(@"[RequestHistory] add response item");
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue