I have an array of UIImages I want split into two separate arrays, one containing objects whose index is even, and the other with objects whose index is odd.
Here's the code I'm using:
var evenImages: [UIImage]?
var oddImages: [UIImage]?
var imageArray: [UIImage]? {
didSet{
for z in 0..<((imageArray?.count)!) {
if z % 2 == 0 {
evenImages?.append(imageArray![z])
} else {
oddImages?.append(imageArray![z])
}
print(evenImages?.count) //prints nil
print(oddImages?.count) //prints nil
}
}
}
The issue so far is that while the objects are seemingly being appended to the appropriate arrays, whenever I try to use them they are nil. Perhaps this is an issue with the order in which the variables are instantiated? Any thoughts?