0
我試圖與PropertyListSerialization字典中迅速2,但是不斷地給出了這樣的錯誤:使用PropertyListSerialization使一個詞典中迅速2
"can not convert value of type 'Int' to expected argument type 'NSPropertyListReadOptions'
我的代碼行是:
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {response,data,error in
if data != nil {
let datasourceDictionary = try! NSPropertyListSerialization.propertyListWithData(data! ,options:Int(NSPropertyListMutabilityOptions.Immutable.rawValue), format: nil)
這:
let datasourceDictionary = try! NSPropertyListSerialization.propertyListWithData(data! ,options:Int(NSPropertyListMutabilityOptions.Immutable.rawValue), format: nil)
之後,我不得不遍歷所有的字典:
for(key, value): (AnyObject, AnyObject) in datasourceDictionary {
let name = key as? String
let url = NSURL(string:value as? String ?? "")
if name != nil && url != nil {
let photoRecord = PhotoRecord(name:name!, url:url!)
self.photos.append(photoRecord)
}
}
福氣 - 給予好評 – muescha
{ 「大塊頭」 =「http://www.sxc.hu/pic/m/n/納克/ ngould/325616_big_fella.jpg「; 「Camino al volcan」=「http://www.sxc.hu/pic/m/r/ro/rockberto/489892_camino_al_volcan_.jpg」; Cheetah =「http://www.sxc.hu/pic/m/n/ng/ngould/329660_cheetah_1.jpg」; } 得到這個。 –