我想在一个单独的swift文件(Login.swift)上设置一个NSUserDefaults变量来确定我的用户是否已登录。如果用户确实已登录,LoginViewController将消失,并且HomeViewController将会所示。但是我正在抛出这个错误UIViewController实例问题
在类型'UIViewController'上使用实例成员'dismissViewControllerAnimated';你的意思是使用'UIViewController'类型的值吗?
这是我的代码
//success
else if value["username"] != nil && value["password"] == nil && value["message"] == nil
{
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isUserLoggedIn")
LoginViewController.dismissViewControllerAnimated(true, completion:nil)
if let api_key = value["api_token"].string
{
print("The token is " + api_key)
}
else
{
print("error parsing api token")
}
//pass data to Users class
_ = Users.init(Name: value["name"].string, Email: value["email"].string, Id: value["id"].int, ProfilePicture: value["profile_picture"].string, Username: value["username"].string)
}
dismissViewControllerAnimated是和对象方法,为什么你使用类名称来调用它。 –