Hi,
I have two UIImage arrays, [images1] and [images2} each consisting of 6 jpg images that are in my project. I want to create an array majorPixArray of these arrays. I keep getting different errors. My swift code an explanations are below.
import UIKit
class StoryViewController: UIViewController {
let images1 : [UIImage] = [
UIImage(named: "bathing1.jpg")!, UIImage(named: "bathing2.jpg")!, UIImage(named: "bathing3.jpg")!, UIImage(named: "bathing4.jpg")!, UIImage(named: "bathing5.jpg")!, UIImage(named: "bathing6.jpg")! ]
let images2 : [UIImage] = [
UIImage(named: "goodssport1.jpg")!, UIImage(named: "goodssport2.jpg")!, UIImage(named: "goodssport3.jpg")!, UIImage(named: "goodssport4.jpg")!, UIImage(named: "goodssport5.jpg")!, UIImage(named: "goodssport6.jpg")! ]
*** let majorPixArray : [[UIImage]] = [[images1], [images2]]
override func viewDidLoad() {
etc., etc.
The *** line throws an error: "Cannot use instance member 'images1' within property initializer; property initializers run before 'self' is available"
If I try to put the *** line in as a function later in the code after view did load, like this:
func putInPix() {
let majorPixArray : [[UIImage]] = [[images1], [images2]]
}
i get the error there as : Cannot convert value of type '[UIImage]' to expected element type 'UIImage'
So I guess what I'm asking is how to define and initialize an array of UIImage arrays? Thanks.