我目前正在开发一个iOS应用程序,需要将数据存储在数据库中(而不是本地)。我对Core Data做了一些研究,但我想将数据存储在web服务器上。有什么建议吗?
谢谢
发布于 2013-03-14 14:07:22
您必须通过一些应用程序接口(如RESTful服务)来实现。我会这样做:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://my.website.com/restService"]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[[NSString stringWithString:@"value1=test&value2=test2"] dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *urlResponse = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];发布于 2013-03-14 14:12:12
如果你想在服务器上存储数据,但你没有服务器,-you可以使用以下方法之一: 1) iCloud 2)解析-你可以在parse.com上创建数据库,并通过Parse API直接使用该数据库。有关更多详细信息,请查看https://parse.com/docs/index。
https://stackoverflow.com/questions/15402247
复制相似问题