This code is causing my application to crash and I can't figure out a way to fix it. The error is : fatal error: unexpectedly found nil while unwrapping an Optional value
Any idea how I can fix it? The two lines I'm returning in my createCharacters() function is whats causing the crash:
class NACharacters {
var featuredImage : UIImage!
init(featuredImage: UIImage){
self.featuredImage = featuredImage
}
static func createCharacters() -> [NACharacters]{
return[
//THE TWO LINES BELOW CAUSE THE CRASH
NACharacters(featuredImage: UIImage(named: "Diplo Squad")!),
NACharacters(featuredImage: UIImage(named: "StopIcon")!)
]
}
}
Solution: I simply needed to delete the space between "Diplo" and "Squad". It seems this was returning nil.