快速完成块中的EXC_BAD_INSTRUCTION

时间:2017-01-19 11:30:27

标签: ios swift

我在执行此代码时遇到错误。我使用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 
    )

1 个答案:

答案 0 :(得分:0)

我通过将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)")
    }
})