Mac OS X开发学习
代码如下:NSOpenPanel *openPanel = ;
;
openPanel.allowedFileTypes = ;
openPanel.directoryURL = nil;
completionHandler:^(NSModalResponse returnCode) {
if (returnCode == 1) {
NSURL *fileUrl = [ objectAtIndex:0];
// 获取文件内容
NSFileHandle *fileHandle = ;
NSString *fileContext = [ initWithData:fileHandle.readDataToEndOfFile encoding:NSUTF8StringEncoding];
// 将 获取的数据传递给 ViewController 的 TextView
ViewController *mainViewController = (ViewController *).contentViewController;
mainViewController.showCodeTextView.string = fileContext;
}
}];
页:
[1]