6

I need to add video and audio recording functionality to an existing app that uses Core Data. I've been thinking that I should save them to the file system and reference them using Core Data but I wondered if I can put them into Core Data as Transformable attributes and ignore the file system altogether?

My gut feeling is that this is a Really Bad Idea™. I do like the ease and value-add of using Core Data however.. I've tried searching for 'iphone core data video' but that just returns heaps of core data tutorials.

nikkumang
  • 1,615
  • 2
  • 17
  • 34

2 Answers2

16

Don't put binary data in Core Data. Store them on the file system and store a reference to the file system location in Core Data.

If you store them in Core Data you risk blowing the cache and causing terrible performance, not to mention probably blowing out memory as you try to fault in a large amount of data.

Marcus S. Zarra
  • 46,571
  • 9
  • 101
  • 182
3

Coredata has a 'allow external storage' option when saving binary data with coredata which will automatically store files larger than 1mb to the disk.

However, this question is very similar to these questions:

https://softwareengineering.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database

and

Storing large (e.g. image/movie) files in Core Data on the iPhone

In contrast to the selected answer, Core Data should be able to maintain good performance as long as there isn't a huge amount of videos or photos.

Community
  • 1
  • 1
Isaac Paul
  • 1,959
  • 2
  • 15
  • 20