0

Here's a rough representation of the data structure:

[
"recipeName" : [

"ingredients" : [String],
"rating" : Int,
"picture" : UIImage,
"url" : URL ]
]

Since storing large amount of images would require all the data to be loaded in memory while performing SQL queries, I was advised against using CoreData.

Currently I'm trying to store around 1000 objects as blob using NSCoder.

Given that this project intends to provide iCloud backup as well, is it ideal to store the large amount of data using NSCoder as opposed to CoreData performance-wise. I'm really new to persistent storage and their performance implications, please help me. Thank you.

as diu
  • 1,010
  • 15
  • 31
  • 3
    NSCoding is great if you ask me and the new Codable protocol is awesome. I would however recommend saving the images separately to a file path and save the file path with the main object. That way you could asynchronously deal with the images but load the objects quickly. Use a UUID to create the path for each image and save it to the object. Hope this makes sense. As far as Core Data the queries are more powerful. To search NSCoding objects you have to load them which is not the case of Core Data. Another possibility would be Realm which has aspects of both. Good luck. – agibson007 Jul 16 '17 at 15:41
  • @agibson007 thanks for your answer! I have a follow up question, do ALL NSCoding objects (all 1000 objects in my case) need to be unarchived before one of them can be made searchable? Is there a way to implement searching them without unarchiving ALL of them? Thanks again for your reply! – as diu Jul 16 '17 at 23:11
  • 1
    the short answer is yes it all needs unarchived and although many sites say the speed is slow I have found it is still unarchived relatively fast. There are ways I could think of to mitigate this with file path names and such. Realm becomes a good choice though because it is like core data in terms of queries and NSCoding in terms of ease. CloudKit has strong query ability so NSCoding + CloudKit would probably be good. – agibson007 Jul 17 '17 at 01:58
  • @agibson007 thank you Sir! Will definite look into Realm and NSCoding+CloudKit – as diu Jul 17 '17 at 03:45

0 Answers0