连接到服务器,检索数据,并将其存储在本地数据库中 [英] Connecting to server, retrieving data, and storing that on local database

查看:58
本文介绍了连接到服务器,检索数据,并将其存储在本地数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这次不是本地问题,我现在必须连接到远程服务器并从那里获取信息,而这些信息我想存储在我的i​​Phone应用程序的本地数据库中.我什至不知道如何开始这个过程.另一个问题是我也需要从给定路径中检索图像并将该图像存储在本地文件夹中.

This time it's not about local problem, I now have to connect to remote server and fetch information from there, and that information I want to store in my local database of an iPhone application. I don't have any clue of even how to start this process. Another issue is I need to retrive an Image too from given path and to store that image in my local folder.

请帮助我.

谢谢

推荐答案

如果可以选择通过HTTP提取信息,我建议您研究出色的 ASIHTTPRequest 库.至于在本地存储此信息,请查看Apple的核心数据框架-Xcode内置了对该框架的支持.

If fetching the information over HTTP is an option, I'd recommend you look into the excellent ASIHTTPRequest library. As for storing this information locally, take a look at Apple's Core Data framework—support for this framework is built into Xcode.

从URL检索图像非常简单:

Retrieving an image from a URL is fairly straightforward:

// Assuming imageURL is the image's URL as an NSURL.
UIImage *image = [UIImage initWithData:[NSData dataWithContentsOfURL:imageURL]];

然后您可以将该图像存储在应用程序的documents文件夹中,或作为原始数据存储在核心数据中.

You can then store this image in your application's documents folder or as raw data in core data.

这篇关于连接到服务器,检索数据,并将其存储在本地数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆