0

I have this Array in a swift IOS App. I want it to be both editable and permanently stored on the App. NSFileManager doesn't like the fact the Array contains tuples. Is there any way round that or does anyone have any suggestions as to how else I could store it?

var topicBook = [("Name",["Species"],"Subject","Rotation","Unit","extra",[(0,0)],"content"),("Name",["Species"],"Subject","Rotation","Unit","extra",[(0,0)],"contentTwo"),("Name",["Species"],"Subject","Rotation","Unit","extra",[(0,0)],"contentThree")]**strong text**
  • 2
    You are not showing enough code. What means "doesn't like"? What means "store"? – matt Jul 19 '15 at 17:32
  • As mentioned we need more info. But if you want to save it to a file you can: http://stackoverflow.com/questions/24097826/read-and-write-data-from-text-file – Aggressor Jul 19 '15 at 17:35

1 Answers1

1

From Apple in The Swift Programming Langauge:

Tuples are useful for temporary groups of related values. They are not suited to the creation of complex data structures. If your data structure is likely to persist beyond a temporary scope, model it as a class or structure, rather than as a tuple. For more information, see Classes and Structures.

And your tuple is pretty complex, so whether or not you need to persist the data I'd recommend using a struct or class anyway. Otherwise it will inevitably become hard to read and work with and will hurt the productivity of you and anyone you're working with that has to use it.

Patrick Lynch
  • 2,742
  • 1
  • 16
  • 18