• Krunal Satao
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
iOS app crashes while setting value of field in date format. Here is what happens we change a date field in our app, we create a salesforce request using salesforce REST API. The SFRestAPI class cannot convert that date filed into proper serialized JSON and causes app to crash throwing an error -  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__NSDate)'

And here is the stack trace - 

*** First throw call stack:

(

    0   CoreFoundation                      0x043731e4 __exceptionPreprocess + 180

    1   libobjc.A.dylib                     0x03f648e5 objc_exception_throw + 44

    2   CoreFoundation                      0x04372fbb +[NSException raise:format:] + 139

    3   Foundation                          0x03a9b2e0 _writeJSONValue + 771

    4   Foundation                          0x03a9f7a2 ___writeJSONObject_block_invoke + 225

    5   CoreFoundation                      0x043fca7a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106

    6   CoreFoundation                      0x043fc97e -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 190

    7   CoreFoundation                      0x04361125 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53

    8   Foundation                          0x03a9f35f _writeJSONObject + 363

    9   Foundation                          0x03a9b1ec _writeJSONValue + 527

    10  Foundation                          0x03a9af9d -[_NSJSONWriter dataWithRootObject:options:error:] + 125

    11  Foundation                          0x03a9db57 +[NSJSONSerialization dataWithJSONObject:options:error:] + 369

    12  intouch.incall                      0x00b1bfc1 NRMA__ptrIntPtrParamHandler + 124

    13  intouch.incall                      0x00b1b504 NRMA__blk_ptrIntPtrParamHandler + 64

    14  intouch.incall                      0x004efbee +[SFJsonUtils JSONDataRepresentation:] + 90

    15  intouch.incall                      0x004efb34 +[SFJsonUtils JSONRepresentation:] + 43

    16  intouch.incall                      0x0084b233 __22-[SFRestRequest send:]_block_invoke + 43

    17  intouch.incall                      0x00851b01 -[MKNetworkOperation encodedPostDataString] + 141

    18  intouch.incall                      0x00857585 -[MKNetworkOperation bodyData] + 1872

    19  intouch.incall                      0x00858404 -[MKNetworkOperation start] + 1179

    20  Foundation                          0x03a2df44 __NSOQSchedule_f + 62

    21  libdispatch.dylib                   0x046b74d0 _dispatch_client_callout + 14

    22  libdispatch.dylib                   0x046a3fe0 _dispatch_async_redirect_invoke + 202

    23  libdispatch.dylib                   0x046b74d0 _dispatch_client_callout + 14

    24  libdispatch.dylib                   0x046a5eb7 _dispatch_root_queue_drain + 291

    25  libdispatch.dylib                   0x046a6127 _dispatch_worker_thread2 + 39

    26  libsystem_pthread.dylib             0x049e6dab _pthread_wqthread + 336

    27  libsystem_pthread.dylib             0x049eacce start_wqthread + 30

)

libc++abi.dylib: terminating with uncaught exception of type NSException