【发布时间】:2009-08-26 17:59:20
【问题描述】:
这是一个非常新手的问题,这是我以前做过很多次的事情,但这次我错过了一些东西。
在我的 AppDelegate.h 文件中,我声明了一个 NSArray 并将其设置为属性:
@interface AppDelegate : NSObject {
NSArray *lines;
}
@property(readwrite, retain) NSArray *lines;
@end
然后在 awakeFromNib 方法的 AppDelegate.m 文件中分配它:
lines = [[NSArray alloc] init];
然后我有一个设置lines数组的方法:
NSString *fileContents = [NSString stringWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop/sometextfile.txt"] encoding:NSUTF8StringEncoding error:NULL];
lines = [fileContents componentsSeparatedByString:@"\n"];
我有一个绑定到AppDelegate.self.lines 的数组控制器,然后我有一个绑定到Array Controller.arrangedObjects 的表列。我可以确认数组正在更新(使用 NSLog 测试)但是表的内容没有更新(它仍然是空白的)。
我在这里遗漏了什么明显的东西吗?
【问题讨论】:
-
不要做
error:NULL。该陈述中有许多可能出错的地方,您确实不想不想知道发生了什么。
标签: objective-c cocoa cocoa-bindings nstableview