0

我正在我的 iOS 应用程序中集成 payU money。除了一件事,一切都很好。每当我从 payU 货币页面返回时,我存储在 UserDefaults 中的所有值都会被删除。我正在使用此代码。

func startPaymentFlow() -> Void {
    UserDefaults.standard.set( "test" , forKey: "test")

    Toast(text:"Please wait.... Generating hash from server").show()
    let paymentVC : PUMMainVController = PUMMainVController()
    var paymentNavController : UINavigationController;
    paymentNavController = UINavigationController(rootViewController: paymentVC)

    self.present(paymentNavController, animated: true, completion: nil)    
}

func transactionCompleted(withResponse response : NSDictionary,errorDescription error:NSError) -> Void {

    self.dismiss(animated: true){
        self.showAlertViewWithTitle(title: "Message", message: "congrats! Payment is Successful")
        self.Status = "1"
        self.MobilePaymentUpdateApi()
    }

}

func transactinFailed(withResponse response : NSDictionary,errorDescription error:NSError) -> Void {    
    self.dismiss(animated: true){
        self.showAlertViewWithTitle(title: "Message", message: "Oops!!! Payment Failed")
        self.Status = "-1"
        self.MobilePaymentUpdateApi()
    }
}

func transactinCanceledByUser() -> Void {

    print(UserDefaults.standard.value(forKey: "test") as! String)

    self.dismiss(animated: true){    
        self.showAlertViewWithTitle(title: "Message", message: "Payment Cancelled ")
        self.Status = "-1"
        print(self.Status)
        self.MobilePaymentUpdateApi()
    }
}

这是错误日志和代码

在执行之后得到这个

  self.present(paymentNavController, animated: true, completion: nil)  

*** -[NSKeyedUnarchiver initForReadingWithData:]: 数据为 NULL

4

0 回答 0