[ERROR] fatal error: unexpectedly found nil while unwrapping an Optional value

2016. 7. 6. 12:53Programming/Swift

반응형

* 원본 소스

let URL = NSURL(string: "https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907")!


* 에러 발생

fatal error: unexpectedly found nil while unwrapping an Optional value


* 해결

var stringUrl = "https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907"

let URL = NSURL(string: stringUrl.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)!



반응형