我有一个简单的(我认为)问题:
我有一部 iPhone。他创建了一个 plist 文件并保存它。我想将此文件上传到服务器上。
然后,我将与另外 3 部 iPhone 下载此 plist 文件并解密信息。
我的问题是:如何将此 plist 文件上传到服务器! 我没有任何 FTP 服务器或其他服务器...我可以使用 Dropbox 来代替吗? 或者是 iPhone 之间通信的其他方式(私有(private) - 不适用于 AppStore)?
非常感谢您的回答!
最佳答案
是的,您可以使用Dropbox API将 plist 上传到 Dropbox 用户的文件夹中。
先检查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);
}
编辑: (如果需要,您可以从应用程序的 Documents 文件夹中加载 plist。请记住,mainBundle 是只读的,因此您无法修改主包中的 plist,只能读取它)..like这个:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *plistFilePath = [[paths objectAtIndex:0]stringByAppendingPathComponent:@"info.plist"];
NSDictionary *plistFile = [[NSMutableDictionary alloc] initWithContentsOfFile:plistFilePath];
关于iphone - Xcode 在服务器上上传 plist 文件 (iPhone),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9648548/