Reputation: 1472
I try to create new array of UIImage objects:
var images = [UIImage](repeating: nil, count: 10)
for i in 0..<10
{
images[i] = ...
}
But I got this error (at first row): Expression type [UIImage] is ambiguous without more context
Upvotes: 0
Views: 1590
Reputation: 449
You are trying to declare an array with UIImage
objects and then instantiating with nil. Try
var images = [UIImage?](repeating: nil, count: 10)
and then handle images being nil when you access them.
If you already know how you are going to populate images, you can use the map function for arrays like so:
var images = (0..<10).map { (i) -> UIImage in
return UIImage() // however you are trying to get the UIImage
}
Upvotes: 2