This my code
var changePhoto = [UIImage]()
let photoPng = UIImage(named: "1.png")
let photoJpg = UIImage(named: "1.jpg")
changePhoto += photoPng
changePhoto += photoJpg
but error "expected declaration"
Please help me! What's wrong?
This my code
var changePhoto = [UIImage]()
let photoPng = UIImage(named: "1.png")
let photoJpg = UIImage(named: "1.jpg")
changePhoto += photoPng
changePhoto += photoJpg
but error "expected declaration"
Please help me! What's wrong?
You need to use the append method to add new objects to your array:
changePhoto.append(photoPng)
changePhoto.append(photoJpg)
Also, you only can have functionality inside of methods. So try to call it inside a method. for example if you use a Viewcontroller in your viewDidLoad method.