I am trying to storing struct values into array and same array I want to store it into User-default and retrieve to show tableview.
struct item:Codable {
var title : String!
var size : String!
init(title: String, size: String) {
self.title = title
self.size = size
}
}
I am using below method for storing
UserDefaults.standard.set(try? PropertyListEncoder().encode(items), forKey:"items")
And get it back
if let data = UserDefaults.standard.value(forKey:"items") as? Data {
let items_user = try? PropertyListDecoder().decode(Array<item>.self, from: data)
print("*************\(String(describing: items_user))")
}
But output getting
Optional([ZLib.item(title: Swift.ImplicitlyUnwrappedOptional<Swift.String>.some("con-smash.gsheet"), size: Swift.ImplicitlyUnwrappedOptional<Swift.String>.some("120 KB"))])
How to remove above optional
and ZLib.item(
, Swift.ImplicitlyUnwrappedOptional<Swift.String>.some(
unnecessary info.