Here is the code I am using:
NSFileManager* defaultMgr = [NSFileManager defaultManager];
if (![defaultMgr fileExistsAtPath:path]) {
return nil;
}
Where path is a url to a file on the system like: "file://localhost/private/var/mobile/Applications/blahblahblah"
This crashes with SIGABRT when the call to fileExistsAtPath: is made. The file does exist, and perhaps the string format isn't what this method would prefer, but it should just return NO. This code is part of a very popular library, and while I don't strictly need to check the existence of the path, I really want to understand what is happening here, in case I ever need to use this method directly.
Particularly:
One more detail: I am running this on my iPhone 4 device with iOS 4.1
A few issues come to mind:
1) NSFileManager works with paths not URLs. No need for "file://".
2) It needs NSStrings like @"...".
3) You should try to keep you filepaths within your application's sandbox.