0
我的要求是用戶必須瀏覽最後訪問的網頁,從而保存陣列來userDefault
我想的陣列的UIViewController保存到NSUserDefault但應用程序崩潰每次
let array = self.navigationController?.viewControllers
UserDefaults.standard.set(array, forKey: "LastNavigationArray")
對於此嘗試崩潰是
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object (
另外,我已經嘗試使用以下代碼b UT斯達康沒有運氣
let array = self.navigationController?.viewControllers
let encodedData = NSKeyedArchiver.archivedData(withRootObject: array)
UserDefaults.standard.set(encodedData, forKey: "LastNavigationArray")
對於這種崩潰是
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.'
如果這是錯誤的,請建議我來實現它的正確方法。 因爲我有非常複雜的導航流。
崩潰與您根據日誌保存數組無關! –
@kapsym不,它與同一日誌崩潰 –
@kapsym你想讓我把整個堆棧跟蹤? –