How to store large arrays in core data?

  Kiến thức lập trình

I have an entity called AudioFile in my core data database. It has attributes like name, artist, file extension and more which are all string. An audio file is unique as long as both name and file extension are different.

I also have a struct called “UpNextItem” which have identical attributes to “AudioFile” entity from core data except that there’s an additional id property of type UUID since a user can add multiple instances of the same song.

How do I store a very large array of up next items to disk? Using JSONEncoder is extremely slow too with almost 140% cpu usage and my app hangs.

Or is there a better way to store this? Since audio file and up next item are almost identical?

I’m expecting the user to have 1000s of up next items in an array so it’s actually plenty of data to be stored in an array.

LEAVE A COMMENT