F Gala F Gala - 1 year ago 47
JSON Question

Can't access json value returned from PHP script

My PHP script returns response like

message = "";
response = {
"session_id" = mf6pnrsf931m96g0hc3n4pjbw3;
"session_name" = d72d1363f44031cac4148b0e6fa789d6;
"session_valid" = true;
success = true;

How can I access/print the value of session id/session name in Swift 2.2?
I dont have any problem in storing the value returned by 'session_valid'

Answer Source

What I needed was this-

let response = objectDic.objectForKey("response") as? NSDictionary

followed by

let session_name = response.objectForKey("session_name") as! String