ios - Realm swift : Convert Results to Swift Array

标签 ios swift realm

我要实现的:

class func getSomeObject() -> [SomeObject]? {
    let objects = Realm().objects(SomeObject)

    return objects.count > 0 ? objects : nil
}

如果 Results,我如何将对象返回为 [SomeObject]

最佳答案

很奇怪,答案很直截了当。这是我的做法:

let array = Array(results) // la fin

关于ios - Realm swift : Convert Results to Swift Array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31100011/

相关文章:

ios - 我可以在 didReceiveRemoteNotification : while app is in the background/suspended? 中执行操作吗

由于 docker 容器中的 "database is locked",swift 构建失败?

ios - 使用选项卡栏在两个 View Controller 之间传递时,TableView 不更新

ios - Realm swift 线程安全变量

objective-c - 从 iOS 设备上传图片到服务器

c# - 如何删除xamarin形式的操作栏?

iOS: `UICollectionview`,如何通过它的 `contentoffset` 获取单元格的 `indexPath`

swift - 无法使 IAP 在模拟器的沙箱 (SWIFT) 中工作

ios - 在自动释放池中使用 Realm 的正确方法是什么?

iOS App Rejection 由于 2.23 - Realm 数据库