Use optional bindings:
let myString = "00012"
if let myInt = Int(myString) {
let imageName = "name_\(myInt)"
let image = UIImage(named: imageName)
}
alternatively use regular expression:
let myString = "00012"
let myStringWithoutLeadingZeros = myString.replacingOccurrences(of: "^0+", with: "", options: .regularExpression)
let imageName = "name_" + myStringWithoutLeadingZeros
let image = UIImage(named: imageName)
solved Int to non optional string