这段代码编译得很好
let ciImage = CIImage(image:UIImage())
Run Code Online (Sandbox Code Playgroud)
然而,当我把它移动到延伸 UIImage
extension UIImage {
func foo() {
let ciImage = CIImage(image:UIImage()) // compile error
}
}
Run Code Online (Sandbox Code Playgroud)
我得到以下编译错误
Cannot call value of non-function type 'CIImage?'
为什么?
使用Xcode Playground 7.1.1进行测试.和Swift 2.1
为什么 Swift Int 扩展中不允许 max( : :) 和 min( : :) ,例如:
extension Int {
func some(low: Int, high: Int) -> Int {
return max(low, high)
}
}
Run Code Online (Sandbox Code Playgroud)
错误说:Static member 'max' cannot be used on instance of type'Int'