NSTableView 和 NSMutableArray 之间的 Cocoa 绑定拒绝更新

发布于 2024-09-07 07:36:38 字数 1244 浏览 8 评论 0原文

好吧,我对 Obj-C 和 Cocoa 很陌生,但我确信我在这里的绑定是正确的。我一直在谷歌搜索,搜索堆栈溢出,并一次又一次地检查我的值。

所以,这是我的绑定:

它们连接到此类:

@interface TMMaddMangaWindowDelegate : NSWindowController {
...
}
...
@property (copy) NSMutableArray* mangaList;
...
@end



@implementation TMMaddMangaWindowDelegate
...
@synthesize mangaList;
// - (NSMutableArray*) mangaList {
//   NSLog(@"mangaList was called!");
//   return mangaList;
//}
//- (void) setMangaList:(NSMutableArray *) input{
//  NSLog(@"setMangaList was called!");
//  [mangaList autorelease];
//  mangaList = [input retain];
//}
...
-(void) populateList:(NSArray*)list{
    NSMutableArray* newArray = [[NSMutableArray alloc] initWithArray:list];
    NSLog(@"Populating List.");
    for(NSXMLNode* node in list){
        [newArray addObject:node.description];
        //[[self mutableArrayValueForKey:@"mangaList"] addObject:node.description];
            //NSLog(@"%@", node.description);
    }
    [self setMangaList:newArray];
    [[self chapterListDownloadIndicator] stopAnimation:self];
}

如您所见,我还尝试了 mutableArrayValueForKey方法,但一无所获。我知道事实上 mangaList 正在获得物品。

我已经为此工作了一段时间,并且可能犯了一个愚蠢的错误。

提前致谢。

Ok, I'm very new to Obj-C and Cocoa, but I'm sure my bindings here are correct. I've been googling, searching stack overflow and have checked my values again and again.

So, here are my bindings:

They connect to this class:

@interface TMMaddMangaWindowDelegate : NSWindowController {
...
}
...
@property (copy) NSMutableArray* mangaList;
...
@end



@implementation TMMaddMangaWindowDelegate
...
@synthesize mangaList;
// - (NSMutableArray*) mangaList {
//   NSLog(@"mangaList was called!");
//   return mangaList;
//}
//- (void) setMangaList:(NSMutableArray *) input{
//  NSLog(@"setMangaList was called!");
//  [mangaList autorelease];
//  mangaList = [input retain];
//}
...
-(void) populateList:(NSArray*)list{
    NSMutableArray* newArray = [[NSMutableArray alloc] initWithArray:list];
    NSLog(@"Populating List.");
    for(NSXMLNode* node in list){
        [newArray addObject:node.description];
        //[[self mutableArrayValueForKey:@"mangaList"] addObject:node.description];
            //NSLog(@"%@", node.description);
    }
    [self setMangaList:newArray];
    [[self chapterListDownloadIndicator] stopAnimation:self];
}

As you can see, I also tried the mutableArrayValueForKey approach, which yielded nothing. I know for a fact mangaList is gaining items.

I've been working on this for a while, and probably made a stupid mistake.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只想待在家 2024-09-14 07:36:38

看起来您正在数组控制器背后更改 mangaList 。每当您对 mangaList 进行更改时,您应该首先调用 [self willChangeValueForKey:@"mangaList"];,然后调用 [self didChangeValueForKey:@"mangaList"] ; 完成更改后。这将使阵列控制器知道它需要查看发生了什么变化。

It looks like you are changing mangaList behind the array controller's back. Whenever you are making a change to mangaList you should first call [self willChangeValueForKey:@"mangaList"]; and then [self didChangeValueForKey:@"mangaList"]; once you are done with the change. this will let the array controller know it needs to take a look at what changed.

浪漫之都 2024-09-14 07:36:38

事实证明,问题在于窗口没有将文件所有者的类标识设置为我的窗口控制器/委托。当我设置它的那一刻,窗口就活了。

这个问题也导致我的 NSProgressIndicator 无法工作。

It turns out that the problem was that the window did not have the class identity of Files Owner set to my window controller/delegate. The moment I set this the window sprang to life.

That problem was also preventing my NSProgressIndicator from working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文