简体   繁体   中英

download image directory from server and store on iphone

I am trying to create a business directory application for my area, I am currently trying to create a sql DB with all of the realivant business information (name, address, opening hours etc). I am then plan to have a physical file directory where all logo images are stored, this directory will be stored somewhere on the server.

When the user starts the applicatoin they will be prompted to download all of the information on business listings (because its for a small community), I will then upload all of the data to the phone using NSURLConnection, the data will be Zlib NSData in the form of XML. I will store all of this data into coredata (which will act as the apps cache).

The next step is to download the directory of images I have stored on the DB.. but I have no idea on the best approach for this and would like some guidance, example code etc.

For instance would it be better to store the images into the sqlDB? I have read this is a bad idea so am trying the approach explained above.

I am still in the process of building the sqlDB but the difficulty I am having is comming up with a way to get the images onto the device and relate them to the correct business using an id field or something simlar.. or is there an easier way to do this?

any help would be appreciated.

Instead of storing the image directly in the DB, you could store the URL to access the image binary instead. This would maintain the relationship with the image without storing the large image data directly in the DB. You could then use the URL retrieved from the DB to download the image on the device and similarly store the path to the downloaded cached image in core data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM