Reputation: 2609
I'm writing an app to consume REST Api which provide JSON
response. I'm using CoreData
to store object from JSON
to support offline feature. Object has some image attributes (Which is image url from JSON response).
My question is should I store image attributes as Data
(Using binary data) to CoreData
(can check use external storage from CoreDataXCModel
) or should I need to only store the image path (As String) and use some library such as Kingfisher
, AlamofireImage
, SDWebImage
to load image from image url stored in Coredata? which one is better design?
1 more thing is for how we handle big image? Can we generate 1 thumbnail which is specific size and 1 full image size.
Upvotes: 0
Views: 169
Reputation: 80
I suggest you to store URL in database and use some framework like SDWebImage to load. These frameworks have caching mechanism so that once an image is loaded it gets cached.
You could preferably get a thumbnail image as a link in the JSON response too.
Upvotes: 4
Reputation: 93
Save the urlString, I think, in most cases the urlStrting is a better solution, because in the era of 3 g / 4 g mobile phone App has greater amounts of image data, the local store they are a very difficult thing, unless you have a 1024 TB of the iPhone.
And you should provide an interface, like long press to push an view(Or anything) to tell user they can save the image to local.
Don't forget load local image at first and provide an interface tell user they can remove the local data.
Upvotes: 1