我有一些代码在最新更新之前可以正常工作,更新到最新版本的 Xcode 后,我收到了这个错误
String.Type 没有名为“stringWithContentOfURL”的成员
代码如下。
func searchFlickrForString(searchStr:String, completion:(searchString:String!, flickrPhotos:NSMutableArray!, error:NSError!)->()){
let searchURL:String = FlickrHelper.URLForSearchString(searchStr)
let queue:dispatch_queue_t = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
dispatch_async(queue, {
var error:NSError?
let searchResultString:String! = String.stringWithContentsOfURL(NSURL.URLWithString(searchURL), encoding: NSUTF8StringEncoding, error: &error)
if error != nil{
completion(searchString: searchStr, flickrPhotos: nil, error: error)
}