ios - 快速完成 block 中的 EXC_BAD_INSTRUCTION

标签 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 
    )

最佳答案

我已经通过将 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/

相关文章:

ios - 如何为Apple AppStore创建虚荣网址?

ios - 只 react native 渲染部分

objective-c - 分配和释放问题

ios - 将 SDWebImage 与解析一起使用

cocoa - Swift 和 inout 参数中的闭包捕获变量

ios - 更改字体大小以完全适合按钮内的文本?

ios - 动态添加 UIButtons 到屏幕

ios - Objective c中小时格式的倒数计时器

iOS:MaterialComponents 阴影

arrays - 在对象数组中搜索数组