Swift Casting Generic to Optional with a nil value causes fatalError
问题 Using Swift 2, in my contrived example I am converting a String to an Int or more specifically an Int or an Int? using a generic. In the case where the Int? should be nil the cast will fail with a fatalError: fatal error: unexpectedly found nil while unwrapping an Optional value These look like they may be similar/duplicate questions: Swift - casting a nil core data string as an optional value Swift: detecting an unexpected nil value in a non-optional at runtime: casting as optional fails My