         didSet {
             if let session = session {
                 let data = NSKeyedArchiver.archivedData(withRootObject: session)
-                keychain.setData(data, forKey: sessionKey)
+                keychain[data: sessionKey] = data
             } else {
-                keychain.removeItem(forKey: sessionKey)
+                keychain[sessionKey] = nil
             }
         }
     }


import Foundation
#if os(iOS) || os(OSX)
    import UICKeyChainStore
#endif

// MARK: - Errors


    private static let sessionKey = "sessionKey"

    private static let keychain = Keychain(server: "https://soundcloud.com", protocolType: .https)


    /// The session property is only set when a user has logged in.
    public fileprivate(set) static var session: Session? = {
        if let data = keychain[data: sessionKey],
            let session = NSKeyedUnarchiver.unarchiveObject(with: data) as? Session {
            return session
        }
        return nil
