I want to make it so that there is a delay between each time the "universe" is shown, so that the user can see it at the screen before it changes. As of right now, I can only see the last one, because the other ones update too quickly.
EDIT: So I tried adding a NSTimer to make the action timed, and the app crashes when I run it, and in the console this appears: libc++abi.dylib: terminating with uncaught exception of type NSException
var universeCounter = 0
func paintUniverse () {
var placeCounter = 0
if universeCounter < simulatedUniverse.count {
for place in simulatedUniverse[universeCounter] {
if place == 1 {
self.realCollectionView.cellForItemAtIndexPath(returnTheRightCell(placeCounter))?.contentView.backgroundColor = UIColor.whiteColor()
}
else {
self.realCollectionView.cellForItemAtIndexPath(returnTheRightCell(placeCounter))?.contentView.backgroundColor = UIColor.blackColor()
}
placeCounter++
}
universeCounter++
}
else {
timer.invalidate()
}
}
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "paintUniverse", userInfo: nil, repeats: true)