samedi 30 mai 2015

Swift check if multiple strings are empty throws "Could not find overload for '||' that accepts the supplied arguments"

In the following class:

class User{
    var _id: String?
    var _enabled: Bool?
    var _username: String?
    var _email: String?

    func create(callback: ((error: Bool, message: String?, json: JSON?, user: User?)->Void)?) -> Void{

        // Check the required attributes are filled
        if (_username.isEmpty || _email.isEmpty || _enabled.isEmpty){
            // Do stuff to say error
        }else{
            // Do stuff to say success
        }

    }

}

The if statement throws a compile error of "Could not find overload for '||' that accepts the supplied arguments".

Why is Swift acting like this and how else can you check to see if one or more of multiple strings are empty without using a for loop?

Aucun commentaire:

Enregistrer un commentaire