-2

I keep getting this error:

Bool cannot be used as a boolean; test for '!=nil' instead

I have looked at a couple of answers already online to this problem but i don't seem to understand how to fix this.

override func viewDidAppear(animated: Bool) 
{
    if(!PFUser.currentUser())
    {
        var loginAlert:UIAlertController = UIAlertController(title: "Please Sign up or Log In", message: "Publish your Quote Today", preferredStyle: UIAlertControllerStyle.Alert)

        loginAlert.addTextFieldWithConfigurationHandler({
            textfield in
            textfield.placeholder = "Author or Publisher"
        })

        loginAlert.addTextFieldWithConfigurationHandler({
            textfield in
            textfield.placeholder = "Your Lock"
            textfield.secureTextEntry = true
        })

The error is highlighted on the second line.

dhh
  • 4,289
  • 8
  • 42
  • 59

1 Answers1

0

you are using Objetive-C syntax which is not valid in swift. Better use:

if PFUser.currentUser() == nil {
    // do something
}
Lennet
  • 413
  • 3
  • 10