迁移到heroku后,使用PFRelation崩溃addObject / removeObject

时间:2016-05-11 11:07:05

标签: ios mongodb heroku parse-platform pfrelation

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

1 个答案:

答案 0 :(得分:0)

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

  1. 删除所有安装
  2. 删除所有会话