【问题标题】:Realm LazyFilterBidirectionalCollection error Swift 3领域LazyFilterBidirectionalCollection错误Swift 3
【发布时间】:2016-10-10 10:00:26
【问题描述】:

我刚刚将我的项目更新为 swift 3。

我对 Swift 的特性还是很陌生。 无论如何,我有这个查询的方法女巫工作正常,

func getAllPointsWithCategory(_ idCategory:String) -> [Point] {
    let realm = try! Realm()
    let containingPOI = realm.objects(Point.self).filter({ (poi) -> Bool in
        return poi.categories.contains(where: { (cat) -> Bool in
            return idCategory == cat.id
        })
    })

    return containingPOI
}

更新后我开始收到此错误:

无法将类型“LazyFilterBidirectionalCollection>”的返回表达式转换为返回类型“[Point]”

我做错了什么?

提前感谢您的帮助

【问题讨论】:

    标签: swift realm swift3


    【解决方案1】:

    领域查询返回Results 类型,而不是Array。查看https://github.com/realm/realm-cocoa/issues/1046 了解如何将Results 转换为Array

    【讨论】:

    • 仍然收到错误,为什么我收到“LazyFilterBidirectionalCollection”?这适用于 swift 2.0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多