迁移到 heroku 后,我的代码在将 PFUser 添加到 PFRelation 时崩溃。当托管在 Parse 上时,此代码运行良好。
func blockUser(user : PFUser) -> Void {
PFUser.currentUser()?.relationForKey("blocked").addObject(user)
PFUser.currentUser()?.saveInBackground()
}
现在导致:
2016-05-11 06:51:39.480 APP[69960:7963868] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Operation is invalid after previous operation.'
架构在 mongo 上对我来说看起来不错,但也许不是?
{
"_id": "_User",
"_metadata": {
"class_permissions": {
"get": {
"*": true
},
"find": {
"*": true
},
"update": {
"*": true
},
"create": {
"*": true
},
"delete": {
"*": true
},
"addField": {
"*": true
},
"readUserFields": [],
"writeUserFields": []
},
"auth_options": {
"anonymous": {
"enabled": false
},
"_enable_by_default": false,
"username": {
"enabled": true
},
"facebook": {
"enabled": false
},
"twitter": {
"enabled": false
}
}
},
"emailVerified": "boolean",
"username": "string",
"email": "string",
"dateOfBirth": "date",
"location": "geopoint",
"blocked": "relation<_User>",
"showAge": "boolean"
}
调用栈:
*** First throw call stack:
(
0 CoreFoundation 0x000000010d4d4d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010cf48deb objc_exception_throw + 48
2 CoreFoundation 0x000000010d4d4cbd +[NSException raise:format:] + 205
3 Parse 0x000000010b113f07 -[PFRelationOperation applyToValue:forKey:] + 951
4 Parse 0x000000010b16bef6 +[PFObjectUtilities newValueByApplyingFieldOperation:toDictionary:forKey:] + 166
5 Parse 0x000000010b161f19 -[PFObjectEstimatedData applyFieldOperation:forKey:] + 121
6 Parse 0x000000010b149759 -[PFObject(Private) performOperation:forKey:] + 153
7 Parse 0x000000010b1ba442 __24-[PFRelation addObject:]_block_invoke_2 + 290
8 Parse 0x000000010b1ba292 __24-[PFRelation addObject:]_block_invoke + 146
9 libdispatch.dylib 0x000000010e61c3eb _dispatch_client_callout + 8
10 libdispatch.dylib 0x000000010e600ef5 _dispatch_barrier_sync_f_invoke + 393
11 Parse 0x000000010b1ba13e -[PFRelation addObject:] + 270
12 APP 0x000000010a273eb4 _TFC8APP21ProfileViewController9blockUserfCSo6PFUserT_ + 1380