ドロップボックス フォルダーに .plist としてアップロードしたい xml 文字列があります。
現在、NSDictionaryを作成して一時フォルダーを作成し、その一時フォルダーに辞書をplistとして書き込み、その一時フォルダーにある.plistをドロップボックスにアップロードします。
これは良いプログラミング ソリューションではないと思います。
これは正常に動作します
if([title isEqualToString:@"Upload to Dropbox"])
{
//pass string in memory to nsdictionary
NSData * data = [_uploadPlistString dataUsingEncoding:NSUTF8StringEncoding];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSDictionary *uploadFile= (NSDictionary*)[NSPropertyListSerialization
propertyListFromData:data
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format
errorDescription:&errorDesc];
//create a temp folder
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"temp"];
NSLog(@"documents datapath: %@",dataPath);
//check if folder exist
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; //Create folder
//write dictionary to plist
NSString *pathTemp = [dataPath stringByAppendingPathComponent:@"agenda.plist"];
// write plist to disk
[uploadFile writeToFile:pathTemp atomically:YES];
//get last created file name from singleton
SingletonClass *sharedInstance=[SingletonClass sharedInstance];
NSString *destDirectory= sharedInstance.lastCreatedFolderName;
//set file name for dropbox
NSString *filename = @"agenda.plist";
[[self restClient] uploadFile:filename toPath:destDirectory
withParentRev:nil fromPath:pathTemp];
}
しかし、メモリ内にある NSDictionary を直接 Dropbox にアップロードするにはどうすればよいですか?
バンドルなどに書き込むことなく。