次のコードを使用してフォルダーを作成しようとすると、YES を返すのではなく、既に存在するフォルダーを作成しようとすると、エラーで NO が返されます。
[[NSFileManager defaultManager] createDirectoryAtPath:[documentsPath stringByAppendingPathComponent:@"temp"] withIntermediateDirectories:NO attributes:nil error:&error];
Apple のドキュメントには次のように書かれています。
Return Value
YES if the directory was created or already exists or NO if an error occurred.
したがって、成功した場合、またはフォルダーが存在する場合はYESを取得する必要があります。しかし、フォルダーが存在する場合、次のメッセージが表示されます。
Error Domain=NSCocoaErrorDomain Code=516 "The operation couldn’t be completed. (Cocoa error 516.)" UserInfo=0x200ef5f0 {NSFilePath=/var/mobile/Applications/DA657A0E-785D-49B4-9258-DF9EBAC5D52A/Documents/temp, NSUnderlyingError=0x200ef590 "The operation couldn’t be completed. File exists"}
これはバグであり、Apple に報告する必要がありますか?