My Requirement is user has to navigate last visited page so
I am trying to save array of UIViewController to NSUserDefault but app is crashing every time
let array = self.navigationController?.viewControllers
UserDefaults.standard.set(array, forKey: "LastNavigationArray")
For this try crash is
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object (
Also, I have tried with following code but no luck
let array = self.navigationController?.viewControllers
let encodedData = NSKeyedArchiver.archivedData(withRootObject: array)
UserDefaults.standard.set(encodedData, forKey: "LastNavigationArray")
For this crash is
Assertion failure in -[UICGColor encodeWithCoder:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UIColor.m:1549
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
If this is wrong please suggest me the correct way to implement it. Because I have very complex navigation flow.