Objective c 基于菜单项更新NSTableView
我正在尝试使用从菜单项中选择的内容更新表视图。这是与NSArrayController绑定的AppDelegate类Objective c 基于菜单项更新NSTableView,objective-c,cocoa,Objective C,Cocoa,我正在尝试使用从菜单项中选择的内容更新表视图。这是与NSArrayController绑定的AppDelegate类 @implementation AppDelegate - (id) init { self = [super init]; // An NSMutableArray to hold several Package objects self.allPackages = [[NSMutableArray alloc] init]; Packag
@implementation AppDelegate
- (id) init {
self = [super init];
// An NSMutableArray to hold several Package objects
self.allPackages = [[NSMutableArray alloc] init];
Package *package = [[Package alloc] init];
// Objective-C setters
[package setName:@"Installation Core"];
[package setCreator:@"Messi"];
[self.allPackages insertObject:package atIndex:[self.allPackages count]];
return self;
}
NSArrayController正在初始化时按预期更新NSTableView。现在我有一个菜单项,它调用一个方法来获取NSArrayController中的一些包对象
- (IBAction)open:(id)sender{
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
....
// If OK Button was pressed
if([openDlg runModal] == NSOKButton){
NSURL *url = [openDlg URL];
PackageHelper *packageHelper = [[PackageHelper alloc] init];
NSMutableArray *files = [packageHelper getFilesFromDirectory: url];
NSLog(@"Received %li",files.count);
// This is actually listing all the files I need.
}
else {
NSLog(@"Pressed Cancel");
}
}
现在我的问题是如何让NSMutableArray文件显示在TableView上?换句话说,数组控制器能否从AppDelegate类中的init方法和不同类中的open方法获取数据
谢谢您的时间。什么课程是
开放的:
在?通常,您会传递指向数组控制器的指针或指向文件数组的指针,具体取决于哪个更有意义。但是很难告诉我们更多的上下文。我在AppDelegate类中有一个open:,与init相同。我无法让ArrayController选择对阵列的更改。所以我继续向应用程序添加了核心数据。现在一切都好了。谢谢