func downloader(downloader: LFDownloader, didFinishWithData data: NSData) {
if downloader.type == 100 {
let jsonData = try! NSJSONSerialization.JSONObjectWithData(data, options:.MutableContainers)
if jsonData.isKindOfClass(NSDictionary.self) {
let dict = jsonData as! Dictionary<String,AnyObject>
let model = DetailItem()
model.setValuesForKeysWithDictionary(dict)
let photoArray = dict["photos"] as! Array<Dictionary<String,AnyObject>>
let tmpArray = NSMutableArray()
for photoDict in photoArray{
let pItem = PhotoItem()
pItem.setValuesForKeysWithDictionary(photoDict)
tmpArray.addObject(pItem)
}
model.photoArray = tmpArray
self.detailItem = model
dispatch_async(dispatch_get_main_queue(), {
self.showDetailData()
})
}
}else if downloader.type == 200{
let jsonData = try! NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers)
if jsonData.isKindOfClass(NSDictionary.self) {
let dict = jsonData as! NSDictionary
let apps = dict["applications"] as! Array<Dictionary<String,AnyObject>>
var nearByArray = Array<LimitModel>()
for appDict in apps{
let model = LimitModel()
model.setValuesForKeysWithDictionary(appDict)
nearByArray.append(model)
}
dispatch_async(dispatch_get_main_queue(), {
self.showNearbyData(nearByArray)
ProgressHUD.hideAfterSuccessOnView(self.view)//这个 也要在 主线程 里面改
//MARK:- 一般修改UI, 要放在主线程序
})
//ProgressHUD.hideAfterSuccessOnView(self.view) ,不行滴
}
dispatch_async(dispatch_get_main_queue(), {
self.showNearbyData(nearByArray)
ProgressHUD.hideAfterSuccessOnView(self.view)//这个 也要在 主线程 里面改
//MARK:- 一般修改UI, 要放在主线程序
})
//ProgressHUD.hideAfterSuccessOnView(self.view) ,不行滴
否则,会出现这种错。
Thunder Strike!
Doctors Preference Notes
2016-08-03 17:40:31.792 1606_LimitFree[2058:151954] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(