gpt4 book ai didi

objective-c - NSTableView 和 NSMutableArray 之间的 Cocoa 绑定(bind)拒绝更新

转载 作者:行者123 更新时间:2023-12-03 17:36:50 26 4
gpt4 key购买 nike

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

所以,这是我的绑定(bind):

他们连接到这个类:

@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 正在获得元素。

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

提前致谢。

最佳答案

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

关于objective-c - NSTableView 和 NSMutableArray 之间的 Cocoa 绑定(bind)拒绝更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3124520/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com