Everything was going great until yesterday. This morning I opened up Xcode and was told updates had occurred and it was converting the Swift code to the new version. NSData
is now returning nil
. It had a value yesterday. Some of the code below that was modified too automatically during the update, however for now until NSData
is fixed that part doesn't matter.
var data : NSData?
let endpoint = NSURL(string: ProductListQuery.toString())
let QOS = Int(QOS_CLASS_USER_INITIATED.rawValue)
dispatch_async(dispatch_get_global_queue(QOS,0))
{
data = NSData(contentsOfURL: endpoint!)
dispatch_async(dispatch_get_main_queue())
{
if (data != nil)
{
if let json: NSDictionary = (try? NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers)) as? NSDictionary
{
if let items = json["result"] as? NSArray
{
for item in items
{
if let p = item as? NSDictionary
{
let lp = LcboProduct(lproduct:p)
self.ProductList.updateValue(lp, forKey:lp.Product_Id())
}
}
}
if let pageinfo = json["pager"] as? NSDictionary
{
self.ProductListQuery.Pager.set_Data(pageinfo)
}
}
}
}
}
return ( ProductList.count > 0)