加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 05:35:22 所属栏目:百科 来源:网络整理
导读:不太明白为什么我在“ Swift 3”中使用“枚举对象”模糊. let collections = PHAssetCollection.fetchAssetCollections(with: .moment,subtype: .any,options: nil) collections.enumerateObjects { (collection,start,stop) in collection as! PHAssetColle
不太明白为什么我在“ 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的答案,解释为什么会发生这种情况.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读