简体   繁体   English

从服务器下载图像目录并存储在iPhone上

[英]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). 我正在尝试为我所在的区域创建一个业务目录应用程序,当前正在尝试创建一个包含所有可实现的业务信息(名称,地址,营业时间等)的sql DB。 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. 当用户启动应用程序时,系统将提示他们下载公司列表中的所有信息(因为是针对小型社区的),然后我将使用NSURLConnection将所有数据上传到手机中,该数据将是XML形式。 I will store all of this data into coredata (which will act as the apps cache). 我将所有这些数据存储到coredata(将用作应用程序缓存)。

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? 例如,将图像存储到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? 我仍在构建sqlDB的过程中,但是我遇到的困难是想出一种方法,可以使用id字段或类似内容将图像粘贴到设备上并将它们与正确的业务相关联。做到这一点的方法?

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. 除了将图像直接存储在数据库中,您还可以存储URL来访问图像二进制文件。 This would maintain the relationship with the image without storing the large image data directly in the DB. 这将保持与图像的关系,而无需将大图像数据直接存储在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. 然后,您可以使用从数据库检索到的URL在设备上下载映像,并类似地将下载的缓存映像的路径存储在核心数据中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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