How can Ioop through an NSMutableArray in Swift? What I have tried:
var vehicles = NSMutableArray()
The array contains objects from class: Vehicle
for vehicle in vehicles {
println(vehicle.registration)
}
I cannot run the above code without the compiler telling me registration
doesn't belong to AnyObject
. At this point I assumed that was because I hadn't told the for loop what type of class item
belongs to. So I modified by code:
for vehicle: Vehicle in vehicles {
println(vehicle.registration)
}
Now the compiler complains about downcasting... how can I simply gain access to the custom registration property whilst looping through the array of Vehicles?