Search code examples
iosswiftalamofire

I am getting this error while calling an API - "Thread 1: EXC_BAD _INSTRUCTION(code = EXC_1386_INVOP,subcode = 0*0)"


Consider:

Image

I am getting this error while calling the API:

Thread 1: EXC_BAD _INSTRUCTION(code = EXC_1386_INVOP,subcode = 0*0)

The main thing is getting the error in the alamofire.swift file.


Solution

  • If you look closely, your error says:

    fatal error: unexpectedly found nil while unwrapping an optional value

    Which means, that a variable that wasn't supposed do be nil, is nil.

    In this code NSURL(URL: URLString.URLString) returns nil.

    Check again what URL are you passing as parameter.