3

This seems to be a common output in the log in xcode, but I haven't found anything that particularly relates to what I am doing. I've consulted YouTube and searched on here for the past couple hours but still haven't found anything.

I'm trying to create an entry in a database (effectively creating a user account) through my app. I'm thinking the error is stemming from JSON conversion, but I'm not totally certain on that.

Here is what my code looks like: (this is further down a nested if-else chain that checks for validity among the fields, and is in a function when the register button is tapped.)

let myURL = URL(string: "http://cgi.soic.indiana.edu/~team12/register.php")
var request = URLRequest(url:myURL!)
request.httpMethod = "POST"

let postString = "username=\(username)&password=\(password)"
request.httpBody = postString.data(using: String.Encoding.utf8)

let task = URLSession.shared.dataTask(with: request as URLRequest) {
    (data, response, error) in

    if error != nil {
        print("error=\(error)")
        return
    }

    var err: NSError?

    do {
        let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary


        if let parseJSON = json {
            let resultValue = parseJSON["status"] as! String
            print("result: \(resultValue)")

            var isUserRegisterd:Bool = false
            if (resultValue == "Success") {
                isUserRegisterd = true
            }

            var messageToDisplay:String = parseJSON["message"] as! String
            if (!isUserRegisterd) {
                messageToDisplay = parseJSON["message"] as! String
            }

            DispatchQueue.main.async {
                let myAlert = UIAlertController(title: "Alert", message:messageToDisplay, preferredStyle: .alert)
                let OKAction = UIAlertAction(title: "OK", style: .default) {
                    (action:UIAlertAction) in
                    self.performSegue(withIdentifier: "registerSuccess", sender: self)
                }
                myAlert.addAction(OKAction)
                self.present(myAlert, animated: true, completion: nil)
            }
        }
    } catch let error as NSError {
        err = error
    }
}

task.resume()

And this is the error I'm receiving when the register button is tapped or I press enter in the last field:

2017-01-05 22:51:25.927582 Freely Market[17933:1522794] [MobileAssetError:29] Unable to copy asset information from https://mesu.apple.com/assets/ for asset type com.apple.MobileAsset.TextInput.SpellChecker
Alert dismissed
2017-01-05 22:51:59.766030 Freely Market[17933:1522809] [] nw_host_stats_add_src recv too small, received 24, expected 28
2017-01-05 22:51:59.769789 Freely Market[17933:1522809] [] ____nwlog_simulate_crash_inner_block_invoke dlopen CrashReporterSupport failed
2017-01-05 22:51:59.770043 Freely Market[17933:1522809] [] __nwlog_err_simulate_crash simulate crash failed "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2017-01-05 22:51:59.770903 Freely Market[17933:1522809] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.30.16
    0   libsystem_network.dylib             0x0000000116f58666 __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x0000000117b24006 nw_socket_add_input_handler + 3164
    2   libnetwork.dylib                    0x0000000117b01555 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x0000000117b00572 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x0000000117aff298 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x0000000117b1aae1 nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x0000000117b1a510 nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x0000000117b321f9 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x0000000116cd5978 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x0000000116cff0cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x0000000116cdce17 _dispatch_queue_serial_drain + 236
    11  libdispatch.dylib                   0x0000000116cddb4b _dispatch_queue_invoke + 1073
    12  libdispatch.dylib                   0x0000000116ce0385 _dispatch_root_queue_drain + 720
    13  libdispatch.dylib                   0x0000000116ce0059 _dispatch_worker_thread3 + 123
    14  libsystem_pthread.dylib             0x00000001170a84de _pthread_wqthread + 1129
    15  libsystem_pthread.dylib             0x00000001170a6341 start_wqthread + 13

Any help would be greatly appreciated as I'm at a loss here. I've been looking through JSON/Swift documents and looking at videos/multiple sites to find out what the issue is, to no avail.

Cheers!

jtbandes
  • 115,675
  • 35
  • 233
  • 266
Quinton Chester
  • 336
  • 4
  • 13
  • 1
    XCode 8 introduced a lot of extraneous console log output, particularly when using the network. You can disable the log info by following instructions here: http://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-8-logs – Mark Glasgow Jan 08 '17 at 00:36
  • @MarkGlasgow that doesn't solve my issue. The issue is that it doesn't seem to be connecting to the database and therefore is not creating a user. Is this not what this error is stating? – Quinton Chester Jan 08 '17 at 17:27
  • It's a bug of xcode. There is a workaround:http://stackoverflow.com/a/41828707/7587102 – Eric Yuan Feb 27 '17 at 04:39

0 Answers0