A preliminary study of class
classperson{var firstname:string var lastname:string init (firstname:string, lastname:string) {Self.fir Stname=firstName Self.lastname=LastName} func out()String {returnSelf.firstname +Self.lastname} func goeast () {self.firstname+="AAA"}}let Person= Person (firstName:"1", LastName:"2") person. out() Person.firstname="3"; let Person2=personperson2.goeast () person2. out() person= = = Person2/*referencing the same piece of address*/structlocation{var x=0.0var y=0.0func out()Float {returnFloat (x +y); } }//The value type method changes itself to declare the keyword mutating//Structural Bodystructlocation2{var x=0var y=0mutating func goeast () {self.x+=1 }}//Enumerationenumswitch{ Case on CaseOff mutating func click () {SwitchSelf { Case . On:self= . Off Case . Off:self= . on}}}var button=Switch.Offbutton.click ()
iOS two development (Swift) class