尝试设置条纹集成代码时出现 EXC_BAD_ACCESS 错误

问题描述

所以我的目标是成功集成这个 API,而不会出现错误的访问错误。我了解此错误意味着以下三种情况之一:对象未初始化、对象已被释放或其他不太可能发生的事情。

我真的无法弄清楚这可能导致问题的原因,我启用了 Zombies 并且当应用程序崩溃时它不会在控制台中打印任何内容

UPDATED ->Myapiclient.swift 文件中,我有这个方法

class Myapiclient: NSObject,STPCustomerEphemeralKeyProvider {

var baseURL: String = "https://us-central1-attend-41f12.cloudfunctions.net/createEphemeralKeys"

let ticketVC: TicketFormViewController = TicketFormViewController()

func createCustomerKey(withAPIVersion apiVersion: String,completion: @escaping STPJSONResponseCompletionBlock) {

    ticketVC.getUseRSStripeCustomerID { (customerid) in
        if let id = customerid {
            Alamofire.AF.request(self.baseURL,method: .post,parameters: [
                "api_version": apiVersion,"customerId": id
            ])
            .validate(statusCode: 200..<300)
            .responseJSON { (responseJSON) in
                switch responseJSON.result {
                case .success(let json):
                    completion(json as? [String: Any],nil)
                case .failure(let error):
                    print("Error creating customer Key (retrieving ephemeral key) with Alamofire. See: Myapiclient - func createCustomerKey")
                    completion(nil,error)
                }
            }
        }
    }
}
}

我需要这个,所以我可以设置 STPPaymentContextSTPCustomerContext,我在 TicketFormViewController() 中做这些:

let customerContext = STPCustomerContext(keyProvider: Myapiclient())
var paymentContext: STPPaymentContext


init() {
    self.paymentContext = STPPaymentContext(customerContext: customerContext)
    super.init(nibName: nil,bundle: nil)
    self.paymentContext.delegate = self
    self.paymentContext.hostViewController = self
    self.paymentContext.paymentAmount = 5000
}

required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

我在 VC 的 extension 中有委托方法,但我认为这些不是问题的一部分,无论如何这些方法都是空的。我不确定这是否完全正确,我基本上只是跟随 Stripe API Docs,但似乎我做错了什么,如果有人能帮助我解决这个问题,那就太好了。

编辑这是错误的图像:

error

在控制台中,我也得到了这个:

warning: Could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

最后,僵尸消息:

objc[19951]: Class _NSZombie_NSURLRequestInternal is implemented in both ?? (0x17023a250) and ?? (0x169773350). One of the two will be used. Which one is undefined.

当我转到包含所有 Stripe STPPaymentContext 集成代码和初始化代码的 vc 时,会立即调用错误。我什至不确定我的方法是否确实向 Firebase Cloud Function 发出请求。我通过按下一个按钮来继续,我在按钮被按下之前放置了断点,我看不到任何可能导致应用程序崩溃的东西。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)