2

I've developed a reading tracking app in Swift and for simplicity's sake I used arrays for my model. It stores some data about the books a user reads and a small image of the cover. I save them to disk periodically for persistence. Now I'm wondering as people use the app, at what point would it be wise to convert my model to using CoreData instead? And would you make that decision based on file size, or number of entries? I ran a test by increasing the number of entries and it seemed like everything worked fine until I started getting into hundreds of entries, at which point the UI started getting laggy. It would probably take a user a pretty long time (years?) to reach that point, but I'd rather know sooner not later if I'm going to have to make a switch.

I've tried searching around for some guidelines and haven't found anything helpful. Anybody with experience out there have any suggestions?

2

I don't think your UI got laggy because the application cannot process data arrays with hundreds of entries. 1000 strings with a length of, say, 100 characters cost around 100kB memory, that's less than all but the most basic images alone.

I suspect something else is happening, like a suboptimal reuse of UITableViewCells (or no reuse at all), or not releasing images when you don't need them anymore. Also, having to scroll through hundreds of entries is probably not what you want your users to do either.

There are many reasons to switch to CoreData or another ORM framework, and if you have big plans for your application it's best to start early instead of converting halfway through the project, but using arrays and storing them as property lists or even flat files still works for very simple apps, even if they contain hundreds or thousands of entries. It tends to get complicated when you store many different types of information (e.g. not only book covers but also detailed author information) and need to combine them; that's where the ORM frameworks will really prove their value.

| improve this answer | |
  • Thanks! I think I’ll stick with the array for now then and troubleshoot the UI issues, which may not even really be an issue since I doubt people will enter 500+ books in the app (and want to scroll through them). I may have to come up with a way to break it up into manageable chunks for the user’s sake. – M. Chollar May 17 '19 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.