Doubts about two Swift errors

4

I'm starting with Swift and he gives me the following error

//Definimos la clase
class Persona {
    //Declaramos las variables
    var nombre: String
    var apellido: String

    //Inicializamos las variables
    init (nombre: String, apellido: String){
        self.nombre = nombre
        self.apellido = apellido
    }
    //Declaramos la propiedads calculada y sus métodos get y set
    var nombreApellido: String {
        get {
            return(nombre + " " + apellido)
        }
        set{
            self.nombre = newValue
            self.apellido = newValue
        }
    }
}
//Accedemos a la propiedad para definir un nombre y un apellido
var yoMisma: Persona = Persona (mombre: "Sara", apellido: "Saez") 


Aquí me da: Incorrect argument label in call (have 'mombre:apellido:', expected 'nombre:apellido:')

//Accedemos a la propiedad para leer su valor
yoMisma.nombreApellido

Here it gives me:

  

Expression resolves to an unused property

Can someone help me please? Thank you Sara

    
asked by sarusky 18.11.2018 в 11:15
source

1 answer

4

You are using the m ombre identifier when the expected is n ombre .

The error message is clear, it is difficult to see, but you should read carefully:

  

Incorrect argument label in call (have ' m ombre: surname:', expected ' n ombre: surname:')

You must correct your code accordingly:

var yoMisma: Persona = Persona (nombre: "Sara", apellido: "Saez") 

Finally, and although it is not part of your doubt, it does not really make sense to me that the property name has a%% co_name. The setter , 100 points, but the getter really does not make sense.

    
answered by 19.11.2018 в 06:53