Alamofire GET request from server API

I'm just getting to know Alamofire (using Alamofire 4 with Xcode 8, Swift3, iOS 10)

I am trying to use the HTTP protocol methods on the server API, given the IP address XXX.XXX.X.XX

To take a snapshot using the SDK that I use, I have to use a GET request. The documentation states the following:

Take a photo GET takepic / true Start the camera to take a picture Return status code http 200 means "OK", "500" means "failure"

The fact is that I am not sure how to successfully receive data from the server, and also do not know how to use this "takepic / true" property, which is provided to me.

I tried to do this:

 Alamofire.request("http://myIPAddress", method: .get).responseJSON { (response) in

        if let status = response.response?.statusCode
        {
            switch(status)
            {
            case 200:
                print("example success")
            case 500:
                print("The response failed")
            default:
                print("error with response status: \(status)")
            }
        }

        if let result = response.result.value
        {
            print(result)
        }

    }

After starting the application, I get a bunch of text in the console. Here are some of them:

nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:

nw_connection_endpoint_report [1 192.168.9.67:80 in_progress socket-flow ()] : start_connect

, , . . โ€‹โ€‹

EDIT: SISocket Cocoapods.

"" :

expression produced error: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x8).

.

+4

Source: https://habr.com/ru/post/1655241/


All Articles