How to store multidimensional array in core data ? Please Help

I want to store 2D and 3D array in core data. I looked everywhere but I could not find anything about it. It would be great if there would any help in this regard

Replies

You'll probably get better engagement in https://forums.developer.apple.com/community/app-frameworks/core-data

hi Dude,


are you trying to store 2D and 3D arrays of other CoreData entities, or are you trying to store 2D and 3D arrays of arrays of (arrays of) Strings, Ints, or something simple like that?


if it's the latter, think about a CoreData entity having an attribute of type Transformable, with its custom type set, for example, to [[String]] for a 2D array of strings (this is Swift syntax). i have used this idea several times before for 1D arrays of UUIDs and of Strings (these are all transformable compliant without any extra work), but haven't encountered a 2D situation; perhaps everything will work equally well for you in a higher dimension? i'd be curious to find out.


alternatively, consider writing your arrays either as json (think Codable), and put that in CoreData, or otherwise writing your own transformer code.


hope that helps,

DMG