saoudrizwan / Disk

Delightful framework for iOS to easily persist structs, images, and data
MIT License
3.08k stars 170 forks source link

Support for reading files from the app bundle? #62

Closed eldare closed 5 years ago

eldare commented 5 years ago

Are there plans to support reading files from app's bundle? thanks.

saoudrizwan commented 5 years ago

I recommend you retrieve anything from the app bundle with Apple's native Bundle API since it's tied to the target which calls it. Meaning if I call Bundle.main from Disk, it will get the file from the Disk target and not your app's. Once you have the url from the Bundle API, it's up to you how you want to deserialize that data. Also, you can read the app bundle's file, but you can't write to it, so it's kind of an anti-pattern for Disk. If you want to modify a file read from the app bundle, you need to first read it (with the Bundle API), save it to the documents directory (with Disk) and then you can read/write the file after this initial set up work.