Xcode上传一个plist文件在服务器上(iPhone)

问题描述:

我有一个简单的(我认为)的问题:Xcode上传一个plist文件在服务器上(iPhone)

我有一个iPhone。他创建一个plist文件并保存。我想在服务器上上传这个文件。

然后,与其他3个iPhone,我将下载此plist文件并解密信息。

我的问题是:如何将这个plist文件上传到服务器! 我没有任何FTP服务器或其他...我可以用Dropbox来代替吗? 或者是iPhone之间进行通信的另一种方式(私有 - 不适用于AppStore)?

非常感谢您的回答!

是的,您可以使用Dropbox API在Dropbox用户的文件夹中上传plist。

首先检查this link设置你的项目

您可以使用这些片段(from this page):

NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; 
NSString *filename = @"Info.plist"; 
NSString *destDir = @"/"; 
[[self restClient] uploadFile:filename toPath:destDir 
        withParentRev:nil fromPath:localPath]; 

然后实现回调

- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath 
    from:(NSString*)srcPath metadata:(DBMetadata*)metadata { 

    NSLog(@"File uploaded successfully to path: %@", metadata.path); 
} 

- (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error { 
    NSLog(@"File upload failed with error - %@", error); 
} 

编辑: (如果您想要,您可以从a的Documents文件夹中加载plist第记得mainBundle是只读的,所以你不能修改驻留在主束plist中,你只能读它)..这样的:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
NSString *plistFilePath = [[paths objectAtIndex:0]stringByAppendingPathComponent:@"info.plist"]; 
NSDictionary *plistFile = [[NSMutableDictionary alloc] initWithContentsOfFile:plistFilePath]; 
+0

你是一个高手!非常感谢您的帮助 ! – 2012-03-10 21:35:34

+0

有一个小问题(对不起)! 如何从我的应用程序的Documents文件夹加载plist?它被称为“Menu.plist” 再次感谢您! – 2012-03-10 22:36:10

+0

@WaesAntoine检查我的edit..remember检查答案接受(并upvote它,如果你想)如果它对你有用:) – Mat 2012-03-13 01:09:24