It is necessary with the help of SwiftyJSON from VK json response to get some values, for example, id from the first items. (beginning of the sample answer from the official api VK)
response: { count: 617, items: [{ id: 67640, from_id: -86529522, owner_id: -86529522, date: 1465326080, post_type: 'post', text: 'Создатель [club41960539|Крошки Ши] на VK Fest' For this I try to use the following code.
let urlPath: String = "https://api.vk.com/method/wall.get" let url: NSURL = NSURL(string: urlPath)! let request1: NSMutableURLRequest = NSMutableURLRequest(URL: url) request1.HTTPMethod = "POST" let stringPost="access_token=" + token // Key and Value let data = stringPost.dataUsingEncoding(NSUTF8StringEncoding) request1.timeoutInterval = 60 request1.HTTPBody=data request1.HTTPShouldHandleCookies=false let queue:NSOperationQueue = NSOperationQueue() NSURLConnection.sendAsynchronousRequest(request1, queue: queue, completionHandler:{ (response: NSURLResponse?, data: NSData?, error: NSError?) -> Void in do { if let jsonResult = try JSON(data: data!) as? JSON { print("ASynchronous\(jsonResult)end") if let id = jsonResult["response"]["items"][0]["id"].string { print("\(id) ID") } But the line if let id = jsonResult ["response"] ["items"] [0] ["id"]. String is never true, i.e. where it appears nil. At the same time, I tried to output jsonResult to the terminal, it can be seen there
{ "response" : [ 655, { "id" : 830, "comments" : { "count" : 0, "can_post" : 1 }, "reply_count" : 0, "can_delete" : 1, A little bit is not what is described in the official api VKontakte. Where do I make a mistake?