Oauth1错误常量Swift iOs

时间:2017-03-07 04:42:41

标签: ios swift

import UIKit

class Base: NSObject {

let dataShared = UserDefaults.standard

func saveUser(user: User) {

    self.dataShared.setObject(user.token, forKey: Constants.OAUTH_TOKEN)
    self.dataShared.setObject(user.secret, forKey: Constants.OAUTH_TOKEN_SECRET)
    self.dataShared.setObject(user.id, forKey: Constants.USER_ID)
    self.dataShared.setObject(user.identifier, forKey: Constants.USER_IDENTIFIER)
    self.dataShared.setObject(user.fullName, forKey: Constants.USER_NAME)
    self.dataShared.setObject(user.crop, forKey: Constants.USER_CROP)
    self.dataShared.setObject(user.state, forKey: Constants.USER_STATE)
    self.dataShared.setObject(user.birthDate, forKey: Constants.USER_BIRTH_DATE)
    self.dataShared.setObject(user.location, forKey: Constants.USER_LOCATION)
    self.dataShared.setObject(user.channelGroup, forKey: Constants.USER_CHANNEL_GROUP)
    self.dataShared.setObject(user.subdistrict, forKey: Constants.USER_SUBDISTRICT)
    self.dataShared.setObject(user.hasStore, forKey: Constants.USER_HAS_STORE)
    self.dataShared.setObject(user.storeId, forKey: Constants.USER_STORE_ID)
    self.dataShared.setObject(user.type, forKey: Constants.USER_TYPE)
    self.dataShared.setObject(user.privacy, forKey: Constants.USER_PRIVACY)
    self.dataShared.setObject(user.communityId, forKey: Constants.USER_COMMUNITYID)
    self.dataShared.setObject(user.customerId, forKey: Constants.USER_CUSTOMERID)
    self.dataShared.setObject(user.points, forKey: Constants.USER_POINTS)
    self.dataShared.setObject(user.avatar, forKey: Constants.USER_AVATAR)
    self.dataShared.setObject(user.forums, forKey: Constants.USER_FORUMS)
    self.dataShared.setObject(user.questions, forKey: Constants.USER_QUESTIONS)
    self.dataShared.setObject(user.articles, forKey: Constants.USER_ARTICLES)
    self.dataShared.setObject(user.responses, forKey: Constants.USER_RESPONSES)
}

}

问题是什么?我得到了Contstant Unsolve Indetifier

我使用了https://github.com/OAuthSwift/OAuthSwift

中的OauthSwift库

我该如何更改此代码?

1 个答案:

答案 0 :(得分:0)

此示例中的常量只是一个包含变量的swift文件。他们没有将它作为一个类实现。所以只需使用变量名而不是Constants.variablename直接访问它们。