I am trying to create a function that takes a username as a parameter and checks to see if that username is taken (by comparing it to other PFUsers in the Parse database. This function is in my view controller class. (I know there are similar questions to this but they do not provide quality answers and are more general than this or are not in Swift).
<configuration>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
The problem is that the condition in the if statement is always false so "Username is available" always prints in the console even if the username is taken."Username is taken" is never printed even when the username is taken. What should I put in the nested if statement to check if the username matches another PFUser?
答案 0 :(得分:3)
You are querying for SELECT
SUM(CONVERT(decimal(8, 2), [can] / 1.2)) + SUM(CONVERT(decimal(8, 2), [carton] / 1.2)) AS [N],
CONVERT(decimal(8, 2), ((SUM(CONVERT(decimal(8, 2), [can] / 1.2)) + SUM(CONVERT(decimal(8, 2), [carton] / 1.2))) * 0.2)) AS [V]
(class) key, but you need to query for a specific key, for example User
.
email
答案 1 :(得分:1)
以为我会把它扔到那里,因为人们似乎并不知道I've answered a similar question before。 Parse会自动对用户类进行这种检查。如果您尝试使用Parse(即用户名,电子邮件等)中重复的任何默认字段创建新用户,则Parse将 不允许用户注册。< / em> 这是自动完成的,您不得不做任何事情,除了出现错误以便用户知道他们为什么无法成功注册。签名用户签名用户名电子邮件等重复项的示例如下:
user.signUpInBackgroundWithBlock {
(succeeded: Bool, signupError: NSError?)
-> Void in
if signupError == nil {
//present new controller
println("Signed up")
}
else {
if let errorString = signupError!.userInfo?["error"] as? NSString
{
error = errorString as String
}
else {
error = "We're sorry, an error ocured! Please try again."
}
self.displayAlert("Could not sign up", error: error)
}
}
}
答案 2 :(得分:0)
检查错误代码。上次我这样做,代码202 =用户名拍摄,代码203 =电子邮件。
require