Swift 3 – PHFetchResult – 枚举对象 – 模糊使用’枚举对象’

Swift 3 – PHFetchResult – 枚举对象 – 模糊使用’枚举对象’,第1张

概述不太明白为什么我在“ Swift 3”中使用“枚举对象”模糊. let collections = PHAssetCollection.fetchAssetCollections(with: .moment, subtype: .any, options: nil) collections.enumerateObjects { (collection, start, stop) in 不太明白为什么我在“ Swift 3”中使用“枚举对象”模糊.
let collections = PHAssetCollection.fetchAssetCollections(with: .moment,subtype: .any,options: nil)    collections.enumerateObjects { (collection,start,stop) in        collection as! PHAssetCollection        let assets = PHAsset.fetchAssets(in: collection,options: nil)        assets.enumerateObjects({ (object,count,stop) in            content.append(object)        })    }

有什么想法吗?此代码在Swift 2.2中正常工作

我已经碰到了这几次,这似乎是Swift的尾随关闭语法的一个问题.包括闭包参数周围的括号应该做的诀窍:
collections.enumerateObjects({ (collection,stop) in    collection as! PHAssetCollection    let assets = PHAsset.fetchAssets(in: collection,options: nil)    assets.enumerateObjects({ (object,stop) in        content.append(object)    })})

编辑:请参阅rinTaro的答案,解释为什么会发生这种情况.

总结

以上是内存溢出为你收集整理的Swift 3 – PHFetchResult – 枚举对象 – 模糊使用’枚举对象’全部内容,希望文章能够帮你解决Swift 3 – PHFetchResult – 枚举对象 – 模糊使用’枚举对象’所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1038870.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存