我正在使用基于 NSOutlineView 的视图,并且我想将 NSSlider 和 NSTextfield 绑定到 NSDictionary 键(@""duration")。字典是我的 NSTableCellView 子类的属性。尝试设置时遇到错误绑定:
错误 :
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSApplication 0x100506400> addObserver:<NSTextValueBinder 0x102609a90> forKeyPath:@"info.duration" options:0 context:0x10260c820] was sent to an object that is not KVC-compliant for the "info" property.'
。H:
#import <Cocoa/Cocoa.h>
@interface ObjectFileTableCellView : NSTableCellView {
NSTextField *_textFieldFilePath;
NSTextField *_textFieldDesription;
NSButton *_checkBox;
NSDictionary* _info;
NSSlider* _slider;
NSTextField* _labelStartTime;
}
@property(retain) IBOutlet NSTextField *textFieldFilePath;
@property(retain) IBOutlet NSTextField *textFieldDescription;
@property(retain) IBOutlet NSTextField *labelStartTime;
@property(retain) IBOutlet NSSlider *slider;
@property(retain) IBOutlet NSButton *checkBox;
@property(retain) NSDictionary* info;
@end
.m:
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item{
if ([[tableColumn identifier] isEqualToString:@"Files"]) {
if ([item isKindOfClass:[OMN_Object class]])
{
//DONE - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item{ if ([[tableColumn identifier] isEqualToString:@"Files"]) {
if ([item isKindOfClass:[OMN_Object class]])
{
OMN_Object *o = item;
ObjectFileTableCellView *v = [outlineView makeViewWithIdentifier:@"FileCell" owner:self]; // File'S owner
hide = NO;
NSString* d = [o.fileInfoDetails valueForKey:@"duration"];
[v.slider setMinValue:0];
[v.slider setMaxValue:[d doubleValue]];
NSString *val = [NSString stringWithFormat:@"%f", v.slider.doubleValue];
[v.labelStartTime setStringValue:val];
[o.fileInfoDetails setValue:val forKey:@"startTime"];
v.info = o.fileInfoDetails;
...
我的 NSOutlineView 视图:
NSTable 列:
NSTextField 绑定设置:
想要的结果:
如何设置绑定以获得我想要的?