作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Xcode,使用基础 SDK 和部署目标进行构建:OS X 10.8
,尝试使用 offical documentation 中的 [NSOpenPanel directoryURL]
说是
Available in OS X v10.6 and later
但我收到错误:
ARC Semantic issue - No visible @interface for 'NSOpenPanel' declares the selector 'directoryURL:'
代码:
#import <Cocoa/Cocoa.h>
// #import <NSOpenPanel.h> // No good
@import AppKit;
void fileOpen()
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
// [openPanel setDirectory:@""]; // works, but deprecated in OSX 10.6
[openPanel directoryURL: [NSURL URLWithString:@"file:///path/"]];
// ...
}
那么我在这里做错了什么?
最佳答案
directoryURL
是一个属性,并不像您最初猜测的那样采用字符串参数。这就是您在尝试解析 directoryURL:'
选择器时看到错误的原因。
不过,directoryURL
属性确实有 getter 和 setter。
尝试使用:
[openPanel setDirectoryURL: [NSURL URLWithString:@"file:///path/"]];
或者:
openPanel.directoryURL = [NSURL fileURLWithPath:@"path"];
关于objective-c - .[NSOpenPanel目录URL]给出错误: No visible @interface for 'NSOpenPanel' declares the selector 'directoryURL:' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32812446/
我是一名优秀的程序员,十分优秀!