Lessons learned in developing some useful things.
Keep looking, Don't settle.
자주 쓸 것 같아 책보고 처음 작성해보고 저장용으로 기록해 둠. (Swift 3.x, Xcode 8.x)
if let url = URL(string: "http://ip.jsontest.com/") { let urlSession = URLSession.shared let task = urlSession.dataTask(with: url, completionHandler: { (data, response, error) in if let nsstr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue) { let str = String(nsstr) // Print raw string print(str) do { let dic = try JSONSerialization.jsonObject( with: str.data(using: String.Encoding.utf8)!, options:JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary // Print dictionary print(dic) if let ipAddress = dic["ip"] { // Print value print(ipAddress) } } catch { print("error occured") } } }) task.resume() }