I'm working on an app that handles text files.
On the open dialog accessory view, when the user choses a file I want to display on a NSPopUpButton the supported encodings for the selected file, but so far the only way I could find to test if a file can be opened with a certain encoding is to actually trying to load it to a NSString.
Right now I'm doing this for each encoding:
NSString *fileContents = [NSString stringWithContentsOfURL:selectedURL encoding:encoding error:nil];
if (fileContents)
{
/* Add encoding to the list of supported encodings */
}
This loads the whole file to the fileContents
object.
Is it possible possible to only test if the file can be loaded without actually loading it?