Reputation: 172
I am building a puzzle in Swift that I would like to store a multiDimensional Array to storage. I have a number of options for this including NSDefaults, Core, Plists, among others. I know that if I do this in NSDefaults that I am essentially bringing the multiDimensional array back out and saving it each time I make a change. This could be disk intensive.
The MultiDimensional Array would be: [30x20] in size. Any recommendations on how best to store this.
I've tried looking at a number of guides and while NSDefaults looks to be the easiest I am concerned about the performance (and I'd like to learn how to do it the right way).
Any guidance is greatly appreciated. I was able to get Core working, but nothing this complex.
Thank you.
Upvotes: 2
Views: 797
Reputation: 558
Declare properties as show in above image & set custom Class as Array<Array<Any>>
in Attributes model:
Declare properties in CoreDataProperties class like:
@NSManaged public var routes: Array<Array<Any>> //
Usages:
While using initialise properties like:
<your_rroperty_name> = obj["routes"] as? [[String]] ?? [[]]
Upvotes: 3
Reputation: 172
I actually tried a number of ways including core data, plists, sqlite, and ultimately ended up using Realm. It was much easier than the others and is really fast. I highly recommend it if you're getting stuck on this like I was:
https://realm.io/docs/swift/latest/
I am actually removing all of my plists in favor of Realm at this point due to the ease of use and simple view.
Upvotes: 0