Core Data for iOS Store in External Record File Core Data for iOS Store in External Record File ios ios

Core Data for iOS Store in External Record File


who's right ?

the iOS docset for the NSAttributeDescription class does mention the allowsExternalBinaryDataStorage and the setAllowsExternalBinaryDataStorage: methods so there is little chance that there is a mistake from Apple.

are you doing something wrong or is slow anyway ?

You said that

The attribute is a Transformable type

But Core Data has a Binary data type. Maybe only this one is linked to the external storage capability.

if that's not it, we don't have enough info here:

  • How many pictures do you store ?
  • What are their sizes ? 
  • Do you automatically fetch all the images ?

Also, the Apple doc states that:

Core Data heuristically decides on a per-value basis…

  • Did you use a migration or are you starting from scratch ?

You could have a look in your app's sandbox to see if your pictures are really saved outside of CoreData.

Hope this helps.


Good question!

Check this post:Storing blobs in external location using built-in CoreData option

Apparently it should work. You should also try it in the simulator and inspect the application data folder to see if the folders are created as described (~/Library/Application Support/iPhone Simulator/... - you will figure out the rest of the path). Also you could inspect the sqlite file with the sqlite3 command to see if the binary data is in the database.

I haven't personally used this option as I would prefer to go for manually saving the images in a folder and store a reference to them in the database instead. This way it will be easier to create UIImage object from the file to be displayed, would have better control on what goes where and so on and so forth. Will take some extra labour though!

Hope that helps you out.