简体   繁体   English

如何检查解析中的课程? -迅捷

[英]How do I check a class in parse? - Swift

My program is set up so you log in, and you choose to upgrade. 我的程序已设置好,因此您可以登录,然后选择升级。 So you login and it saves your username and password into the "User" class of parse, then when you upgrade your account it stores all the information it had you input, ie. 因此,您登录后,它将用户名和密码保存到parse的“ User”类中,然后在升级帐户时,它将存储您输入的所有信息,即。 Phone number, etc. I also have it store your username, and this is in the "Upgrade" class. 电话号码等。我也将其存储您的用户名,这在“升级”类中。 But when I log in, I want my program to check if the user upgraded their account. 但是,当我登录时,我希望程序检查用户是否升级了帐户。 My current code: 我当前的代码:

@IBAction func loginButton(sender: AnyObject) {

var username = self.usernameTextField.text
var pasword = self.passwordTextField.text

if (password.isEmpty) { 

Here I have an UIAlert which is unimportant 这里我有一个不重要的UIAlert

}
else {
PFUser.logInWithUsernameInBackground(username, password: password, block: {( user, error) ->Void in
if ((user) != nil) {

Here is the issue. 这是问题。 Right here is the point where I wuold perform my segue if they are a regular user. 就在这里,如果他们是普通用户,我将执行我的搜索。 But within this statement I want to put another statement to check if it is an upgraded account. 但是在此语句中,我想添加另一条语句来检查它是否为升级帐户。 I have tried this: 我已经试过了:

var upgradeUser:PFObject = PFObject(className: "Business")

I tried declaring that but now what do I put in my if statement? 我试图声明这一点,但是现在我应该在if语句中输入什么? Essentially I need something like this: 本质上,我需要这样的东西:

if (upgradeUser has the current user's username) {
self.performSegueWithIdentifier("LoginSegue2", sender: nil)
}

I tried using wherekeys and findobjectWithId, but none seem to work.I just need to login with user, then check the upgrade class if this user's username is found within that class. 我尝试使用wherekeys和findobjectWithId,但似乎都没有用。我只需要登录用户,然后检查升级类(如果在该类中找到了该用户的用户名)。 Any suggestions? 有什么建议么? Or proper ways to use what I have already tried? 还是使用我已经尝试过的正确方法?

PFUser是PFObject的子类,因此您可以在PFUser对象上使用setObject:forKey:并将其设置为bool( 如何设置bool ),即userIsUpgraded:true/false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM