UserDefaults.standard数据已删除(payU money)

时间:2017-07-27 10:58:39

标签: ios swift3 nsuserdefaults payment-gateway payumoney

我正在将payU资金整合到我的iOS应用中。除了一件事,一切都很好。每当我从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

0 个答案:

没有答案