【发布时间】:2016-05-18 10:18:46
【问题描述】:
例如,这个 sn-p 取自 Swift 中的UIColor 定义:
// Access the underlying CGColor or CIColor.
public var CGColor: CGColor { get }
但是,在我自己的班级中尝试对 NSError 做同样的事情会导致错误:
public class MyClass {
public var NSError: NSError {
return NSError(domain: "mydomain", code: 0, userInfo: [:])
}
}
var 行显示Use of undeclared type 'NSError'。
这还有可能吗?有什么好的方法可以做到这一点?
苹果 Swift 2.2 版 (swiftlang-703.0.18.1 clang-703.0.29)
目标:x86_64-apple-macosx10.9
【问题讨论】:
-
通过简单的
Foo类确认
标签: swift