last day (15 days later) » 

11:18 PM
0
A: How to Receive JSON Response in Swift 3

DenisInstead of using let parseJSON = json?["TYPE"] try: let parseJSON = recJson?["TYPE"] Also, try printing both: print(data) print(recJson) To make sure you are getting a response. Sort of like process of elimination.

 
Thanks for the quick response. Unfortunately, it didn't work, but here was the output: Connected to xxx.xxx.xxx.xxx on port 8889 data: 0 bytes recJSON: nil parseJSON: nil Disconnecting Error: Error
 
Are you getting a response from print(data)?
 
I'm getting the following: data: 0 bytes
 
Ok, so we can see now that its not your receiving json, but your sending json.
 
I added the edit to my original question, since it said the edit queue was busy when trying to add to yours. My send seems to be sending properly, and the server is giving the expected response, at least when looking at the Terminal output
I also just realized I confused the situation. I had tweaked my code in an attempt to make it easily understandable, and put json? instead of recJSON? in the response. I've edited it above. My apologies!
 
11:18 PM
I do it all the time. lol My laptop is dead but the main problem is that your not getting any data back...
I'll get back to you later today
 
Great, thanks. I'll make an edit to my question to avoid further confusion!
 
Hey so I found this function
func socket(socket : GCDAsyncSocket, didReadData data:NSData, withTag tag:Int32)
Do you know how to implement it, or would you like me to show you?
Also, when giving a chunk of code like this. I always try to type out the code and let xcode handle the completion of it. it helps avoid errors.
 
Hi. I've just made a couple of edits, and another attempt with socket.readdata() in the code
I haven't seen that function before. Is it a way of separating the write and read?
 
I'm not really sure, I just found it in the documentation. lol Let me know if you have trouble implementing it
 
Ok, I'll give it a shot
 
11:29 PM
Go basic and just try to get a response back...
 
will do
 

last day (15 days later) »