简体   繁体   中英

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. 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

}
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? 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. Any suggestions? Or proper ways to use what I have already tried?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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