Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mane_ios

macrumors newbie
Original poster
Mar 29, 2016
6
0
Currently, I am working on my first app, the app crashes showing this error message[http://i.stack.imgur.com/Hf5Ce.png] and only (lldb) is displayed in the debugger area. I have attached the backtrace below. Please help me out.

Code:
    lldb) bt
* thread #1: tid = 0x8e27, 0x000000010d581fed MT`MT.VideoModel.(response=Alamofire.Response<AnyObject, Foundation.NSError> @ 0x00007fff52699320, self=0x00007fc8db131a70) -> () -> ()).(closure #1) + 5085 at VideoModel.swift:63, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x000000010d581fed MT`MT.VideoModel.(response=Alamofire.Response<AnyObject, Foundation.NSError> @ 0x00007fff52699320, self=0x00007fc8db131a70) -> () -> ()).(closure #1) + 5085 at VideoModel.swift:63
    frame #1: 0x000000010d90f027 Alamofire`reabstraction thunk helper from @callee_owned ([USER=303582]@owned[/USER] Alamofire.Response<Swift.AnyObject, __ObjC.NSError>) -> (@unowned ()) to @callee_owned (@in Alamofire.Response<Swift.AnyObject, __ObjC.NSError>) -> (@unowned ()) + 151 at ResponseSerialization.swift:0
    frame #2: 0x000000010d90d355 Alamofire`Alamofire.Request.(completionHandler=(Alamofire`partial apply forwarder for reabstraction thunk helper from @callee_owned ([USER=303582]@owned[/USER] Alamofire.Response<Swift.AnyObject, __ObjC.NSError>) -> (@unowned ()) to @callee_owned (@in Alamofire.Response<Swift.AnyObject, __ObjC.NSError>) -> (@unowned ()) at ResponseSerialization.swift), response=<unavailable>) -> (queue : Swift.Optional<__ObjC.OS_dispatch_queue>, responseSerializer : A, completionHandler : (Alamofire.Response<A.SerializedObject, A.ErrorObject>) -> ()) -> Self).(closure #1).(closure #1) + 885 at ResponseSerialization.swift:140
    frame #3: 0x000000010d90bb0a Alamofire`partial apply forwarder for Alamofire.Request.(response <A where A: Alamofire.ResponseSerializerType> (Alamofire.Request) -> (queue : Swift.Optional<__ObjC.OS_dispatch_queue>, responseSerializer : A, completionHandler : (Alamofire.Response<A.SerializedObject, A.ErrorObject>) -> ()) -> Self).(closure #1).(closure #1) + 186 at ResponseSerialization.swift:0
    frame #4: 0x000000010d8efac7 Alamofire`reabstraction thunk helper from @callee_owned () -> (@unowned ()) to @callee_unowned @convention(block) () -> (@unowned ()) + 39 at Upload.swift:0
    frame #5: 0x00000001114abe5d libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #6: 0x00000001114cc49b libdispatch.dylib`_dispatch_client_callout + 8
    frame #7: 0x00000001114b42af libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1738
    frame #8: 0x000000010f374d09 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    frame #9: 0x000000010f3362c9 CoreFoundation`__CFRunLoopRun + 2073
    frame #10: 0x000000010f335828 CoreFoundation`CFRunLoopRunSpecific + 488
    frame #11: 0x0000000112f1bad2 GraphicsServices`GSEventRunModal + 161
    frame #12: 0x000000010f7c1610 UIKit`UIApplicationMain + 171
    frame #13: 0x000000010d5cdd9d MT`main + 109 at AppDelegate.swift:14
    frame #14: 0x000000011150092d libdyld.dylib`start + 1
    frame #15: 0x000000011150092d libdyld.dylib`start + 1
(lldb)
 
Last edited by a moderator:
I can see from this and your other message you're downloading JSON data using AlamoFire and trying to parse it.

What is likely happening is your use of ! which means you have to be 100% sure the data can be retrieved/converted to the type you are specifying. If it isn't you will get a crash.

No one here can verify that. In your other message I looked at the http request and the JSON looked like a mess so the first thing you would need to do is make sure the JSON data is valid and formatted as you want it (dictionary and arrays in valid format). If you are new to Swift this app you are trying to write looks a little more complicated than I would recommend. If you are following a course or tutorial, the author of it might be more useful to asked.
 
I can see from this and your other message you're downloading JSON data using AlamoFire and trying to parse it.

What is likely happening is your use of ! which means you have to be 100% sure the data can be retrieved/converted to the type you are specifying. If it isn't you will get a crash.

No one here can verify that. In your other message I looked at the http request and the JSON looked like a mess so the first thing you would need to do is make sure the JSON data is valid and formatted as you want it (dictionary and arrays in valid format). If you are new to Swift this app you are trying to write looks a little more complicated than I would recommend. If you are following a course or tutorial, the author of it might be more useful to asked.
@tyche thank you so much for responding
 
Yes, parsing JSON data takes a bit of practice and experience.

Mainly you have to understand optionals and unwrapping if you are doing the parsing in Swift. You have to be very careful to validate the JSON before trying to use it. But don't feel bad, even experienced Swift developers make mistakes when parsing JSON.
 
Have you tried SwiftyJSON? It makes parsing JSON so much easier. You can add it via CocoaPods or Carthage or simply copying SwiftyJSON.swift into your project.
 
Yes, parsing JSON data takes a bit of practice and experience.

Mainly you have to understand optionals and unwrapping if you are doing the parsing in Swift. You have to be very careful to validate the JSON before trying to use it. But don't feel bad, even experienced Swift developers make mistakes when parsing JSON.
Thank you so much sir..!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.