I am trying to retrieve a JSON data from responseData.translatedText and my app crashed in valueForKeyPath.
Alamofire.request(.GET, "http:/
.response { (_, _, data, _) in
let translatedText: String? = data?.valueForKeyPath("responseData.translatedText") as! String?
/
if let translated :String = translatedText{
self.textView.text = translated
} else {
self.textView.text = "No translation available."
}
Using default language params
2015-09-28 07:33:51.266 LoveInASnap[2106:192451] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSConcreteMutableData 0x7fe530ed8f90> valueForUndefinedKey:]: this class is not key value coding-compliant for the key responseData.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001072b6f65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001091a5deb objc_exception_throw + 48
2 CoreFoundation 0x00000001072b6ba9 -[NSException raise] + 9
3 Foundation 0x0000000107936e8c -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226
4 Foundation 0x000000010788cf37 -[NSObject(NSKeyValueCoding) valueForKey:] + 280
5 Foundation 0x00000001078a3da4 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 245
6 LoveInASnap 0x0000000106431727 _TFFC11LoveInASnap14ViewController23performImageRecognitionFS0_FCSo7UIImageT_U_FTGSqCSo12NSURLRequest_GSqCSo17NSHTTPURLResponse_GSqCSo6NSData_GSqCSo7NSError__T_ + 215
7 Alamofire 0x00000001095ffaad _TFFFC9Alamofire7Request8responseFS0_FT5queueGSqPSo17OS_dispatch_queue__17completionHandlerFTGSqCSo12NSURLRequest_GSqCSo17NSHTTPURLResponse_GSqCSo6NSData_GSqCSo7NSError__T__DS0_U_FT_T_U_FT_T_ + 301
8 Alamofire 0x00000001095e3317 _TTRXFo__dT__XFdCb__dT__ + 39
9 libdispatch.dylib 0x0000000109d72ef9 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x0000000109d9349b _dispatch_client_callout + 8
11 libdispatch.dylib 0x0000000109d7b34b _dispatch_main_queue_callback_4CF + 1738
12 CoreFoundation 0x00000001072173e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00000001071d8939 __CFRunLoopRun + 2073
14 CoreFoundation 0x00000001071d7e98 CFRunLoopRunSpecific + 488
15 GraphicsServices 0x000000010aa16ad2 GSEventRunModal + 161
16 UIKit 0x0000000107cf6676 UIApplicationMain + 171
17 LoveInASnap 0x000000010643359d main + 109
18 libdyld.dylib 0x0000000109dc792d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)