Try this
EDITED
let myArray = NSMutableArray()
var image:UIImage!
var nimages = 0
for(;;nimages++){
let nameOfImg_ = entity.attribute
let imageName = String(format: "name%@number%lu.jpg", arguments: [nameOfImg_,(nimages + 1)])
if((NSBundle.mainBundle().pathForResource(imageName, ofType: nil)) != nil){
image = UIImage(contentsOfFile: NSBundle.mainBundle().pathForResource(imageName, ofType: nil)!)
myArray.addObject(image!)
}else{
break
}
}
entity.attribute must be a String
12
solved Swift 2 get the number of images in main bundle [closed]