{"action":"created","issue":{"url":"https://api.github.com/repos/leancloud/objc-sdk/issues/88","repository_url":"https://api.github.com/repos/leancloud/objc-sdk","labels_url":"https://api.github.com/repos/leancloud/objc-sdk/issues/88/labels{/name}","comments_url":"https://api.github.com/repos/leancloud/objc-sdk/issues/88/comments","events_url":"https://api.github.com/repos/leancloud/objc-sdk/issues/88/events","html_url":"https://github.com/leancloud/objc-sdk/issues/88","id":188186786,"number":88,"title":"crash when save with option and Date datatype involved","user":{"login":"liyukuang","id":6366049,"avatar_url":"https://avatars.githubusercontent.com/u/6366049?v=3","gravatar_id":"","url":"https://api.github.com/users/liyukuang","html_url":"https://github.com/liyukuang","followers_url":"https://api.github.com/users/liyukuang/followers","following_url":"https://api.github.com/users/liyukuang/following{/other_user}","gists_url":"https://api.github.com/users/liyukuang/gists{/gist_id}","starred_url":"https://api.github.com/users/liyukuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liyukuang/subscriptions","organizations_url":"https://api.github.com/users/liyukuang/orgs","repos_url":"https://api.github.com/users/liyukuang/repos","events_url":"https://api.github.com/users/liyukuang/events{/privacy}","received_events_url":"https://api.github.com/users/liyukuang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-11-09T08:02:27Z","updated_at":"2016-11-22T03:11:43Z","closed_at":null,"body":"在Swift project中使用save with option 会奔溃, 不加上option没有任何问题，希望不是Trump惹的祸！\r\n\r\n\r\n``` swift\r\n       guard let eventObject = AVObject(className: \"className\", objectId: self.objectId) else {\r\n            return\r\n        }\r\n        \r\n        guard let query = AVQuery(className:  \"className\") else {\r\n            return\r\n        }\r\n        query.whereKey(\"key1\", greaterThan: Date())\r\n        query.whereKey(\"key2\", greaterThan: 0)\r\n        \r\n        let option = AVSaveOption()\r\n        option.query = query\r\n        \r\n        eventObject.incrementKey(\"key1\", byAmount: -1)\r\n        eventObject.addUniqueObject(newMember, forKey: \"key2\")\r\n        \r\n        do {\r\n            try eventObject.save(with: option)\r\n        } catch {\r\n            print(\"error\")\r\n        }\r\n\r\n```\r\n\r\n错误信息\r\n``` log\r\n2016-11-08 23:54:05.285 uscfun[58819:2023222] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__NSDate)'\r\n*** First throw call stack:\r\n(\r\n\t0   CoreFoundation                      0x000000010aae334b __exceptionPreprocess + 171\r\n\t1   libobjc.A.dylib                     0x000000010a03121e objc_exception_throw + 48\r\n\t2   CoreFoundation                      0x000000010ab4c265 +[NSException raise:format:] + 197\r\n\t3   Foundation                          0x0000000109b251f4 _writeJSONValue + 668\r\n\t4   Foundation                          0x0000000109b7aa12 ___writeJSONObject_block_invoke + 226\r\n\t5   CoreFoundation                      0x000000010aa6a9d6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102\r\n\t6   CoreFoundation                      0x000000010aa6a8af -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 159\r\n\t7   Foundation                          0x0000000109b7a806 _writeJSONObject + 430\r\n\t8   Foundation                          0x0000000109b250dd _writeJSONValue + 389\r\n\t9   Foundation                          0x0000000109b7aa12 ___writeJSONObject_block_invoke + 226\r\n\t10  CoreFoundation                      0x000000010aa73e55 __65-[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 85\r\n\t11  CoreFoundation                      0x000000010aa73d36 -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 198\r\n\t12  Foundation                          0x0000000109b7a806 _writeJSONObject + 430\r\n\t13  Foundation                          0x0000000109b250dd _writeJSONValue + 389\r\n\t14  Foundation                          0x0000000109b7aa12 ___writeJSONObject_block_invoke + 226\r\n\t15  CoreFoundation                      0x000000010aa6a9d6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102\r\n\t16  CoreFoundation                      0x000000010aa6a8af -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 159\r\n\t17  Foundation                          0x0000000109b7a806 _writeJSONObject + 430\r\n\t18  Foundation                          0x0000000109b250dd _writeJSONValue + 389\r\n\t19  Foundation                          0x0000000109b7aa12 ___writeJSONObject_block_invoke + 226\r\n\t20  CoreFoundation                      0x000000010aa6a9d6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102\r\n\t21  CoreFoundation                      0x000000010aa6a8da -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 202\r\n\t22  Foundation                          0x0000000109b7a806 _writeJSONObject + 430\r\n\t23  Foundation                          0x0000000109b250dd _writeJSONValue + 389\r\n\t24  Foundation                          0x0000000109b25649 ___writeJSONArray_block_invoke + 132\r\n\t25  CoreFoundation                      0x000000010ab3be2a -[__NSSingleObjectArrayI enumerateObjectsWithOptions:usingBlock:] + 58\r\n\t26  Foundation                          0x0000000109b2534f _writeJSONArray + 330\r\n\t27  Foundation                          0x0000000109b25174 _writeJSONValue + 540\r\n\t28  Foundation                          0x0000000109b7aa12 ___writeJSONObject_block_invoke + 226\r\n\t29  CoreFoundation                      0x000000010ab48e83 -[__NSSingleEntryDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 67\r\n\t30  Foundation                          0x0000000109b7a806 _writeJSONObject + 430\r\n\t31  Foundation                          0x0000000109b250dd _writeJSONValue + 389\r\n\t32  Foundation                          0x0000000109b24f04 -[_NSJSONWriter dataWithRootObject:options:error:] + 124\r\n\t33  Foundation                          0x0000000109b24de4 +[NSJSONSerialization dataWithJSONObject:options:error:] + 333\r\n\t34  AVOSCloud                           0x0000000108a0b00c -[LCJSONRequestSerializer requestBySerializingRequest:withParameters:error:] + 1148\r\n\t35  AVOSCloud                           0x000000010895fac7 -[AVPaasClient requestWithPath:method:headers:parameters:] + 1367\r\n\t36  AVOSCloud                           0x0000000108961c9f -[AVPaasClient postBatchSaveObject:headerMap:eventually:block:] + 271\r\n\t37  AVOSCloud                           0x00000001089432c3 -[AVObject sendBatchRequest:eventually:error:] + 1379\r\n\t38  AVOSCloud                           0x00000001089401bf -[AVObject saveWithOption:eventually:verifyBefore:error:] + 799\r\n\t39  AVOSCloud                           0x000000010893fe71 -[AVObject saveWithOption:eventually:error:] + 113\r\n\t40  AVOSCloud                           0x000000010893fdd3 -[AVObject saveWithOption:error:] + 99\r\n\t41  uscfun                              0x000000010866aa0a _TFC6uscfun5Event3addfT9newMemberCSo6AVUser7handlerFTSbGSqPs5Error___T__T_ + 1946\r\n\t42  uscfun                              0x000000010864fe8c _TFC6uscfun25EventDetailViewController9joinEventfT6senderCSo8UIButton_T_ + 396\r\n\t43  uscfun                              0x000000010865060a _TToFC6uscfun25EventDetailViewController9joinEventfT6senderCSo8UIButton_T_ + 58\r\n\t44  UIKit                               0x000000010b7a55b8 -[UIApplication sendAction:to:from:forEvent:] + 83\r\n\t45  UIKit                               0x000000010b92aedd -[UIControl sendAction:to:forEvent:] + 67\r\n\t46  UIKit                               0x000000010b92b1f6 -[UIControl _sendActionsForEvents:withEvent:] + 444\r\n\t47  UIKit                               0x000000010b92a0f2 -[UIControl touchesEnded:withEvent:] + 668\r\n\t48  UIKit                               0x000000010bcdbd94 _UIGestureEnvironmentSortAndSendDelayedTouches + 5645\r\n\t49  UIKit                               0x000000010bcd6a5b _UIGestureEnvironmentUpdate + 1472\r\n\t50  UIKit                               0x000000010bcd6453 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 521\r\n\t51  UIKit                               0x000000010bcd5636 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 286\r\n\t52  UIKit                               0x000000010b8143b9 -[UIWindow sendEvent:] + 3989\r\n\t53  UIKit                               0x000000010b7c163f -[UIApplication sendEvent:] + 371\r\n\t54  UIKit                               0x000000010bfb371d __dispatchPreprocessedEventFromEventQueue + 3248\r\n\t55  UIKit                               0x000000010bfac3c7 __handleEventQueue + 4879\r\n\t56  CoreFoundation                      0x000000010aa88311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17\r\n\t57  CoreFoundation                      0x000000010aa6d59c __CFRunLoopDoSources0 + 556\r\n\t58  CoreFoundation                      0x000000010aa6ca86 __CFRunLoopRun + 918\r\n\t59  CoreFoundation                      0x000000010aa6c494 CFRunLoopRunSpecific + 420\r\n\t60  GraphicsServices                    0x0000000110920a6f GSEventRunModal + 161\r\n\t61  UIKit                               0x000000010b7a3964 UIApplicationMain + 159\r\n\t62  uscfun                              0x00000001086ab75f main + 111\r\n\t63  libdyld.dylib                       0x000000010e7d568d start + 1\r\n)\r\nlibc++abi.dylib: terminating with uncaught exception of type NSException\r\n```"},"comment":{"url":"https://api.github.com/repos/leancloud/objc-sdk/issues/comments/262136063","html_url":"https://github.com/leancloud/objc-sdk/issues/88#issuecomment-262136063","issue_url":"https://api.github.com/repos/leancloud/objc-sdk/issues/88","id":262136063,"user":{"login":"tang3w","id":2226563,"avatar_url":"https://avatars.githubusercontent.com/u/2226563?v=3","gravatar_id":"","url":"https://api.github.com/users/tang3w","html_url":"https://github.com/tang3w","followers_url":"https://api.github.com/users/tang3w/followers","following_url":"https://api.github.com/users/tang3w/following{/other_user}","gists_url":"https://api.github.com/users/tang3w/gists{/gist_id}","starred_url":"https://api.github.com/users/tang3w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tang3w/subscriptions","organizations_url":"https://api.github.com/users/tang3w/orgs","repos_url":"https://api.github.com/users/tang3w/repos","events_url":"https://api.github.com/users/tang3w/events{/privacy}","received_events_url":"https://api.github.com/users/tang3w/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T03:11:43Z","updated_at":"2016-11-22T03:11:43Z","body":"@liyukuang 这的确是个 bug，非常感谢你的反馈。我们会在下个版本中修复。"}}
{"actor":{"display_login":"tang3w"}}