简体   繁体   中英

moveItemAtPath works on iPad, but not on Simulator?

I am using moveItemAtPath call to change a file extension from .PDF to .pdf (just lowercasing it). It fails on the simulator as shown below, but works fine on the device. Could it be some sort of permissions problem?

lowerPDF=[upperPDF stringByReplacingOccurrencesOfString:@".PDF" withString:@".pdf"];
NSLog(@"Lowercasing filename %@ to %@",upperPDF,lowerPDF);
if (![fm moveItemAtPath:upperPDF toPath:lowerPDF error:&error]) 
    NSLog(@"RENAME error %@",[error localizedDescription]);

NextPage[13625:207] Lowercasing filename /Users/scott/Library/Application Support/iPhone Simulator/4.2/Applications/7D38A00A-3990-441C-96C5-DD56EC3B6922/Documents/What a Difference a Day made 24010812.PDF to /Users/scott/Library/Application Support/iPhone Simulator/4.2/Applications/7D38A00A-3990-441C-96C5-DD56EC3B6922/Documents/What a Difference a Day made 24010812.pdf
NextPage[13625:207] RENAME error The operation couldn’t be completed. (Cocoa error 512.)

Thanks,

//Scott

The filesystem on a Mac is normally case-insensitive, while the filesystem on the device is case-sensitive. So on the device, "foo.PDF" and "foo.pdf" are two different files, while on the Mac's filesystem used by the simulator they are the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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