I understand that iOS filenames are case-sensitive while OSX filenames can be case-insensitive. Apple's iCloud design guide says:
"To make your document file format cross-platform compatible, you must read and write files in a case-insensitive manner." (from http://developer.apple.com/library/ios/#documentation/General/Conceptual/iCloudDesignGuide/Chapters/DesigningForDocumentsIniCloud.html)
I want to make my app's file management case-insensitive in iOS. What is the correct way to deal with reading and writing files, and also checking whether files exist (using [NSFileManager fileExistsAtPath:]
) in iOS in a case-insensitive way, both in iCloud and on the local filesystem?
No. MacOS is not a case sensitive file system by default. So you can't have two files named File.
Two files that differ only by case is not allowed. Case-insensitive: This is the file-system used by very old Windows versions and is rarely encountered "in the wild". Two files that differ only by case is not allowed and the case used to create a file is not preserved.
Open Disk Utility, located in the /Applications/Utilities directory. Select Macintosh HD. In the bottom-left corner, check if Case-sensitive is listed.
There is no specific thing that will make iOS case-insensitive. It is what it is. What they are telling you is that you must not rely on case sensitivity (don't create files that differ only by case), and that you shouldn't be sloppy with your use of case (don't create "readme" and then read "Readme").
If you accept arbitrary filenames from the user on iOS, and then plan to send those to iCloud, then you will need to query for all the files that exist on iCloud and verify that there is no case-insensitive conflict (using [NSString caseInsensitiveCompare:]
). This shouldn't come up a lot, though, as long as you're using iCloud exclusively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With