The iPhone SDK docs claim fopen() is a supported method of file access but I am unable to get it to return a FILE handle. I am accessing a directory which is included in my project. I have tried fopen "filename","dir/filename","./filename","./dir/filename","/dir/filename" all returning with a null pointer. Some people report using it with no issue so I am sure it is something simple!
Browse and open files and foldersTap Browse at the bottom of the screen, then tap an item on the Browse screen. If you don't see the Browse screen, tap Browse again. To view recently opened files, tap Recents at the bottom of the screen. To open a file, location, or folder, tap it.
Go to Settings > General > [Device] Storage. You might see a list of recommendations for optimizing your device's storage, followed by a list of installed apps and the amount of storage each one uses. Tap an app's name for more information about its storage. Cached data and temporary data might not be counted as usage.
Apple's Files app lets you view and access files stored on online services, such as iCloud Drive, Box, Dropbox, Google Drive, and Microsoft OneDrive, all in one place. You can also view your files directly on your iPhone or iPad and run a variety of commands on them.
Just to be clear to open a file "some.txt"...
NSString * path = [[NSBundle mainBundle] pathForResource: @"some" ofType: @"txt"];
FILE *f = fopen([path cStringUsingEncoding:1],"r");
if (f == NULL) NSLog([path stringByAppendingString:@" not found"]);
if you're trying to access a file within your application bundle, you need to get the full path to it: [[NSBundle mainBundle] pathForResource: FILENAME ofType: FILEEXTENSION]
This returns an NSString, which you can pull a UTF8String out of and pass to fopen.
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