在快速应用程序中使用Realm DB.我正在尝试使用谓词过滤结果,如下所示:
class func fetchUsersFromDB(usersId: [String]) -> [User]{ var users = [User]() let realm = Realm() let predicate = NSPredicate(format: "objectId IN %@",argumentArray: usersId) var allUsers = realm.objects(User).filter(predicate) users = Array(allUsers) return users }
但这不会编译.我收到此错误:
Terminating app due to uncaught exception 'Invalid value',reason: 'IN clause requires an array of items'
我有什么想法我做错了吗?