Вопрос

i'm archiving and unarchiving data to store data in core data. Does archiving will affect on memory and time(archiving and unarchiving).In my project i'm archiving array of 30 objects(custom) to a single object(NSData) while storing in core data and unarchiving while retrieving.

Это было полезно?

Решение

Archiving does take time (as does everything). For an array of strings with a count of ~30 the time to archive isn't going to be very long. Obviously there are some side effects to archiving in that you can't use the contents of the archive in fetch predicates or sorting. The main thing to be wary of is repeated archiving / unarchiving. If you need access to the contents frequently then you should be using a transient attribute on the entity, unpacking the archive the first time it's accessed and then using the transient cache after that.

The alternative is to create another entity and a relationship to it. This is more flexible, but is generally only worth it if you need access to the contents during fetching or if the array is bigger or you don't always need all of the contents at the same time.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top