gpt4 book ai didi

swift3 - swift 3,PHFetchResult.enumerateObjects 错误

转载 作者:行者123 更新时间:2023-12-02 05:27:18 26 4
gpt4 key购买 nike

在 swift 3 中,该方法向我显示“'enumerateObjects' 的使用不明确”,发生了什么。我该怎么办?

extension PHFetchResult {
public func assetCollection() -> [PHAssetCollection] {
var list :[PHAssetCollection] = []
self.enumerateObjects { (object, index, stop) in
if object is PHAssetCollection {
let collection = object as! PHAssetCollection
list.append(collection)
}
}
return list
}
}

最佳答案

Swift 3.0:只需在 enumerateObjects 之后的大括号之前添加圆括号即可。

extension PHFetchResult {
public func assetCollection() -> [PHAssetCollection] {
var list :[PHAssetCollection] = []
self.enumerateObjects ({ (object, index, stop) in
if object is PHAssetCollection {
let collection = object as! PHAssetCollection
list.append(collection)
}
})
return list
}
}

关于swift3 - swift 3,PHFetchResult.enumerateObjects 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37933244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com