2012-02-09 5 views
4

iCloud에서 일부 파일이있는 폴더를 만들어야합니다. 시도 다음파일이있는 iCloud 폴더 만들기

NSString *folderName = [NSString stringWithFormat:@"folder_%@", [formatter stringFromDate:[NSDate date]]]; 

//iCloud folder 
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; 
NSURL *ubiquitousPackage = [[[ubiq URLByAppendingPathComponent:@"Documents"] URLByAppendingPathComponent:folderName]URLByAppendingPathComponent:@"file.txt"]; 
//NSLog(@"%@",ubiquitousPackage.relativePath); 

File *doc = [[File alloc] initWithFileURL:ubiquitousPackage]; 

[doc saveToURL:[doc fileURL] forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { 

    if (success) 
    { 

    } 
}]; 

그것은 오류를 반환

Foundation called mkdir("/private/var/mobile/Library/Mobile Documents/6CVKW284XZ~com~cloudmy~rom/Documents/folder_20120209_194803/(A Document Being Saved By klp)"), it didn't return 0, and errno was set to 2.

+0

폴더를 만들지 않았지만 확장명이없는 파일입니다. –

답변

0

당신은 같이 파일 이름에 공백 문자를 이스케이프해야 할 수 있습니다

"(A\ Document\ Being\ Saved\ By\ klp)" 

?

+0

작동하지 않습니다. 나는 파일 시스템에 폴더 folder_20120209_194803을 만들었고 모든 좋은 것을 저장했다. 하지만 지금은 폴더를 얻을 수 없습니다. –

+0

[이 예는?] (https://github.com/lichtschlag/iCloudPlayground)를 시도 했습니까? – verec