【问题标题】:NSPopUpButtonCell error when embedded in an NSTableColumn that is bound嵌入到绑定的 NSTableColumn 时出现 NSPopUpButtonCell 错误
【发布时间】:2014-10-10 05:55:01
【问题描述】:

在我的 NSPopUpButtonCell 类型的 NSTableView 中绑定单元格时出现错误

[<NSTableColumn > valueForUndefinedKey:]: this class is not key value coding-compliant for the key value.

现实是我只是将 NSPopUpButtonCell 的内容作为字符串之后

但是我变了

NSString *name;

NSObject *name;

这使我的应用程序加载但在尝试将内容显示到显示 NSPopUpButtonCell 列的 NSTableView 时崩溃

ERROR: unrecognized selector sent to instance

当我有一个 UNBOUND 单元格时,我没有收到错误,如果单元格是 NSTextFieldCell 类型,我没有问题,可以改用 NSString 类。

我猜这是关于将正确的位连接到所有内容,从我在错误中看到的内容来看,那么,我如何让弹出单元格显示弹出按钮但将所选销售的值保存在实际数组?

谢谢

//------------------------------------------------
//my.h
//------------------------------------------------
@interface theItemsInArrayC : NSObject {
@private
    NSString *name;
    int age;
}
@property int age;
@property (copy) NSString *name;
@end

@interface mybigList : NSObject {
@private
    NSMutableArray  *theItems;
}
@property (copy) NSMutableArray  *theItems;
@end
//------------------------------------------------

//------------------------------------------------
//my.m
//------------------------------------------------
@implementation theItemsInArrayC
@synthesize name;
@synthesize age;
- (id)init
{
    self = [super init];
    if (self) {
        age = 19;
        name = @"Another Name";
    }
    return self;
}
@end

@implementation mybigList
@synthesize theItems;
- (id)init
{
    self = [super init];
    if (self) {
        theItems = [[NSMutableArray alloc] init];
    }
    return self;
}
@end
//------------------------------------------------

【问题讨论】:

  • 请描述您在表格列中设置的绑定:哪些绑定?绑定什么?什么控制器键?什么模型键路径?
  • 我实际上发现,在将单元格转换为弹出窗口之前,它是文本和绑定的,当我转换为弹出窗口时,它在底部保持一个杂散绑定,删除那个杂散是解决我的问题的原因跨度>

标签: nstableview key-value-coding nspopupbuttoncell


【解决方案1】:

我在https://github.com/johnjohndoe/NSPopUpButtonCell找到了我想做的示例代码

我希望这可以帮助下一个人! 也非常感谢github上的那个人oooooooo

【讨论】:

    猜你喜欢
    • 2023-03-22
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 1970-01-01
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    相关资源
    最近更新 更多