swift中的JSON解码问题(XCode6 beta2)

时间:2014-06-19 15:59:18

标签: ios xcode uikit swift swift-playground

我刚刚使用restful API做了一个请求和解码数据的小演示, API网址是

http://interface.bilibili.tv/playurl?cid=1168445&otype=json

这是视频网址的API,我在下面编写了代码并在操场上运行

import UIKit

var url = NSURL(string: "http://api.bilibili.tv/view?type=json&id=822920&batch=1&appkey=0a99fa1d87fdd38c")

var data = NSData.dataWithContentsOfURL(url, options: NSDataReadingOptions.DataReadingUncached, error: nil)

var json : AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: nil)

然后Xcode每次都自动退出。 但是,如果我将URL更改为

http://freegeoip.net/json/8.8.8.8

代码运行没有问题。

enter image description here

如果有人能帮助我,我会很感激,这是Xcode 6 beta的错误还是我写错了代码?

Xcode fatal

0 个答案:

没有答案