相关疑难解决方法(0)

不能调用非函数类型'CIImage'的值吗?

这段代码编译得很好

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

14
推荐指数
1
解决办法
2698
查看次数

Swift 中 Int 扩展中的 max(_:_:) 和 min(_:_:)

为什么 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'

max min instancetype swift

4
推荐指数
1
解决办法
696
查看次数

标签 统计

swift ×2

instancetype ×1

max ×1

min ×1