我在我的iOS应用程序中集成了payU资金 . 除了一件事,一切都很好 . 每当我从payU money页面返回时,将删除存储在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()
    }
}

This is error log and code

在执行之后得到这个

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

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