{"action":"closed","issue":{"url":"https://api.github.com/repos/roccoma504/onthemap/issues/13","labels_url":"https://api.github.com/repos/roccoma504/onthemap/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/roccoma504/onthemap/issues/13/comments","events_url":"https://api.github.com/repos/roccoma504/onthemap/issues/13/events","html_url":"https://github.com/roccoma504/onthemap/issues/13","id":120152670,"number":13,"title":"When retrieving data from the server, changing the API key crashes the app.","user":{"login":"roccoma504","id":9686652,"avatar_url":"https://avatars.githubusercontent.com/u/9686652?v=3","gravatar_id":"","url":"https://api.github.com/users/roccoma504","html_url":"https://github.com/roccoma504","followers_url":"https://api.github.com/users/roccoma504/followers","following_url":"https://api.github.com/users/roccoma504/following{/other_user}","gists_url":"https://api.github.com/users/roccoma504/gists{/gist_id}","starred_url":"https://api.github.com/users/roccoma504/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roccoma504/subscriptions","organizations_url":"https://api.github.com/users/roccoma504/orgs","repos_url":"https://api.github.com/users/roccoma504/repos","events_url":"https://api.github.com/users/roccoma504/events{/privacy}","received_events_url":"https://api.github.com/users/roccoma504/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-03T11:47:14Z","updated_at":"2015-12-03T22:12:38Z","closed_at":"2015-12-03T22:12:38Z","body":"I changed the RestAPIKey to create a quasi server error, and the app crashes. \r\n\r\nThe reason is because you assume NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: &parsingError) as! NSDictionary is never nil, but it could be nil.\r\n\r\nYou can set up a control statement to detect if the value is nil or not. Or you can take a look at the code that the coach used in the course (https://github.com/udacity/ios-networking/blob/step-4.15-testing-movie-manager/TheMovieManager/TheMovieManager/TMDBClient.swift), and pay attention to function parseJSONWithCompletionHandler\r\n"}}