iterazione di elementi resa erroreArray of struct a Swift
non riusciva a trovare membro 'convertFromStringInterpolationSegment'
println("\(contacts[count].name)")"
, mentre le stampe dirette voce lista bene.
Cosa mi manca?
struct Person {
var name: String
var surname: String
var phone: String
var isCustomer: Bool
init(name: String, surname: String, phone: String, isCustomer: Bool)
{
self.name = name
self.surname = surname
self.phone = phone
self.isCustomer = isCustomer
}
}
var contacts: [Person] = []
var person1: Person = Person(name: "Jack", surname: "Johnson", phone: "7827493", isCustomer: false)
contacts.append(person1)
var count: Int = 0
for count in contacts {
println("\(contacts[count].name)") // here's where I get an error
}
println(contacts[0].name) // prints just fine - "Jack"
Grazie, Antonio. In realtà è lo stesso che avevo usato in Python. Suppongo che mi stavo complicando troppo il semplice. E i complimenti per ** enumerate **, ho dimenticato che è disponibile in Swift. – thinkswift