I have the following class
class Game {
// An array of player objects
private var playerList: [Player]?
}
I want to enumerate through the playerList; this requires to import Foundation then cast it to a NSArray; but its always complaining that it can't convert it
func hasAchievedGoal() {
if let list:NSArray = playerList {
}
for (index,element) in list.enumerate() {
print("Item \(index): \(element)")
}
}
Cannot convert value of type '[Player]?' to specified type 'NSArray?'
I've tried the below, but that isn't working:
if let list:NSArray = playerList as NSArray