How to logout from vk api on ios?
<p>I've integrated login with vk button in my ios app. And I want to add an ability to switch account.</p>

<p>I've tried to run network request to <code>http://api.vk.com/oauth/logout</code>. But it outputs <code>wrong logout hash</code>.</p>

<p>I used this code:</p>

<pre><code>let logoutUrl = "http://api.vk.com/oauth/logout"

        let request = NSMutableURLRequest(URL: NSURL(string: logoutUrl)!,
        cachePolicy:.ReloadIgnoringLocalCacheData,
        timeoutInterval:60.0)
        let responseData = try! NSURLConnection.sendSynchronousRequest(request, returningResponse: nil)
</code></pre>

<p>Also I tried to clear NSDefaults, after logout:</p>

<pre><code>let defaults = NSUserDefaults.standardUserDefaults()
        defaults.removeObjectForKey("VKAccessUserId")
        defaults.removeObjectForKey("VKAccessToken")
        defaults.removeObjectForKey("VKAccessTokenDate")
        defaults.synchronize()
</code></pre>

<p>And to clear cookies:</p>

<pre><code>let storage = NSHTTPCookieStorage.sharedHTTPCookieStorage()
        for cookie in storage.cookies {
            let domainName = cookie.domain
            let domainRange = domainName.rangeOfString("vk.com")

            if(domainRange.length &gt; 0) {
                storage.deleteCookie(cookie)
            }
        }
</code></pre>

<p>And nothing helps</p>