這裏是我的3個表如何從NSPredicate中獲取連接表中的所有元素? (對於NSFetchedResultsController)
House
-userPermissions: [Permission]
Permission
-house: House
-user: User
-permissionLevel: String
User
-housePermissions: [Permission]
我希望得到所有用戶(不考慮權限級別的),對於一個給定的房子。
我想使用NSFetchedResultsController
(因爲我可能有10k用戶),這意味着我將不得不使用NSPredicate
。
我已經試過以下斷言:
NSPredicate(format: "SELF IN %@[email protected]", house.userAccesses ?? [])
崩潰:Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFSet 0x128f3b070> valueForUndefinedKey:]: this class is not key value coding-compliant for the key user.'
NSPredicate(format: "%@[email protected]", house.userAccesses ?? [])
崩潰:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "%@[email protected]"'