当我执行此代码时,我遇到错误。我使用shopify框架来获取集合,但它使应用程序崩溃。请帮助我
self.client = BUYClient(shopDomain: self.shopDomain, apiKey: self.apiKey, appId: self.appID)
self.client.getCollectionsPage(1, completion: {( collections:[BUYCollection]?, page: UInt, reachedEnd: Bool, error: NSError?) -> Void in
if (collections != nil) && error == nil {
print("fetching collections: \(collections)")
self.data=collections! as NSArray
self.fetchProducts()
}
else {
print("Error fetching collections: \(error!.localizedDescription)")
}
} as! BUYDataCollectionsListBlock //here an error occur
)
最佳答案
我已经通过将 NSError 更改为 ERROR 解决了这个问题
self.client.getCollectionsPage(1, completion: {( collections:[BUYCollection]?, page: UInt, reachedEnd: Bool, error: Error?) -> Void in
if (collections != nil) && error == nil {
print("fetching collections: \(collections)")
self.data=collections! as NSArray
self.fetchProducts()
}
else {
print("Error fetching collections: \(error!.localizedDescription)")
}
})
关于ios - 快速完成 block 中的 EXC_BAD_INSTRUCTION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41740712/