當我嘗試運行這個項目時,我迎來了一個「使用未解析的標識符錯誤」。這裏是代碼我上線的誤差與我不斷收到一個使用未解決的標識符錯誤swift
var jsonDict = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
let task : NSURLSessionDataTask = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in if((error) != nil) { print(error!.localizedDescription) } else { let err: NSError? do { var jsonDict = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary } catch { if(err != nil) { print("JSON Error \(err!.localizedDescription)") } else { //5: Extract the Quotes and Values and send them inside a NSNotification let quotes:NSArray = ((jsonDict.objectForKey("query") as! NSDictionary).objectForKey("results") as! NSDictionary).objectForKey("quote") as! NSArray dispatch_async(dispatch_get_main_queue(), { NSNotificationCenter.defaultCenter().postNotificationName(kNotificationStocksUpdated, object: nil, userInfo: [kNotificationStocksUpdated:quotes]) }) } } } })
可有人請幫助。謝謝。
哪一行,你得到的錯誤? – WMios
是的,它發生在哪條線上? –
@WMios我剛剛更新了代碼,以顯示錯誤的位置 –