1

迁移到 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
4

1 回答 1

0

我不确定以下两个操作中的哪一个(或两个)解决了我的问题,但我在尝试从 PFRelation 添加/删除某些内容时不再崩溃:

  1. 删除所有安装
  2. 删除所有会话
于 2016-06-19T17:12:30.620 回答