简体   繁体   English

Xcode将plist文件上传到服务器(iPhone)

[英]Xcode upload a plist file on a server (iPhone)

I have a simple (I think) question : 我有一个简单的(我认为)问题:

I got an iPhone. 我有一部iPhone。 He create a plist file and he save it. 他创建一个plist文件并保存。 I want to upload this file on a server. 我想将此文件上传到服务器上。

Then, with 3 others iPhone, I will download this plist file and decrypt the informations. 然后,使用其他3个iPhone,我将下载此plist文件并解密信息。

My question is : How can I upload this plist file into a server !! 我的问题是:如何将这个plist文件上传到服务器中! I don't have any FTP server or others ... Can I use instead Dropbox by exemple ? 我没有任何FTP服务器或其他服务器...我可以代替使用Dropbox吗? Or is an other way to communicate between iPhone (private - not for AppStore) ? 还是iPhone之间的另一种通信方式(专用-不适用于AppStore)?

Thanks very much for your answers ! 非常感谢您的回答!

Yes, you can use Dropbox API to upload a plist on the Dropbox user's folder. 是的,您可以使用Dropbox API在Dropbox用户的文件夹上上传一个plist。

Check first this link to setup your project 首先检查此链接以设置您的项目

You can use these snippets ( 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];

then implement the callbacks 然后实现回调

- (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);
}

EDIT : (if you want, you can load the plist from the Documents folder of your app. remember that the mainBundle is read-only so you can't modify the plist that resides in the main bundle, you can only read it)..like this: 编辑 :(如果需要,可以从应用程序的Documents文件夹中加载plist。请记住mainBundle是只读的,因此您不能修改驻留在主捆绑包中的plist,只能读取它)。 。像这样:

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

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

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