last day (15 days later) » 

7:58 PM
3
A: How to retrieve response JSON data with Swift

avismaraYou ARE getting the response JSON. It's just that it is a binarized NSData object which you would want to convert to JSON object, if I am not wrong. Right now, I guess it will print illegible blocks of alpha numeric characters, right? Well, you can do something like: class func searchWithQuer...

 
IT actually doesn't print anything... which is odd.
 
Yes, see the edited answer. Kinda missed a line of code there. My bad.
 
As in nothing is printed, even if i try to serialize the json. Even before that nothing was printing, which seems to be my problem.
 
Oh, looks like there is something wrong with the response. Log the error in the failure block and see if that prints.
 
Check the edited question, i put the error in there
How can I show you the contract?
 
7:58 PM
Do you have an API document that you refer to?
 
I played around with the consumer key and it now generates JSON data. However it has this one thread kill, which is in the updated Question!!!
 
Good! Looks like all the parsing is done for you. Log the response, you'll be done.
 
Do you know why i have the thread kill though?
 
Yes. The runtime is trying to treat the NSDictionary as NSData. Since your response is of type NSDictionary, you might as well log it and get the response. It will be in form of key value pairs.
 
Can you provide the code? I'm not exactly sure what you mean, my english is not good
Sorry, check the updated code with the appropriate jsonobject added...
response is of type anyObject.. It is not of type NSDictionary? I have to explicitly cast response as NSData or else it will not compile
 
7:58 PM
You cast it to NSDictionary first. Like this: let info = response as! NSDictionary. See that it will cast successfully.
 
let JSONObject: AnyObject? = NSJSONSerialization.JSONObjectWithData(response as! NSDictionary, options: NSJSONReadingOptions(0), error: nil) does not work.
 
Log the response. Not the JSON. Wait, I'll correct the answer.
 
I see... that makes so much more sense. Thanks so much!
How come casting the response as an NSDictionary prints it out in JSON format? Sorry, just curious
 
Tell me.
 
We didn't serialize the JSON, so how did it format it into son?
json*
 
8:04 PM
Your framework is doing that heavy part for you.
 
I see, thanks :)
 
It is parsing your JSON and giving the results in the form of JSON dictionary.
 

  last day (15 days later) »