문제

So i have an NSTableView with dynamic NSTableColumns. The columns should get it's data from an NSArrayController's arrangedObject.

Since everything is dynamic, I can't really use the interface builder to bind values. How do I do this programmatically?

I tried this:

NSTableColumn *newColumn = [[NSTableColumn alloc]initWithIdentifier:aKey];
[newColumn.value bind:@"value" toObject:arrayController.arrangedObjects withKeyPath:aKey options:nil];
도움이 되었습니까?

해결책

Okay i figured it out..

NSString *akey = @"somekey";
NSString *keypath = [NSString stringWithFormat:@"arrangedObjects.%@",akey];
[newColumn bind:@"value" toObject:arrayController withKeyPath:keypath options:nil];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top