Question

What could make a file operation that is working well on the simulator, to not be working on an iOS device?

When using [NSBundle mainBundle], and the file is found by FileManager, what could be the different reasons for adjacent file operations to have different outcome?

I am noticing this sometimes, and just want to get an idea of what to think about when this happens.

Was it helpful?

Solution

Seems like you are trying to read a file in your application bundle. You may get its path by code:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"ext"]; //Then you can use NSFileManager to read/copy it

All files in application bundle are readonly. You may get more information from here:

http://developer.apple.com/library/ios/#documentation/CoreFoundation/Conceptual/CFBundles/AccessingaBundlesContents/AccessingaBundlesContents.html#//apple_ref/doc/uid/10000123i-CH104-SW8

OTHER TIPS

As @Aadhira said in the comment above, the simulator stores its files inside a bunch of folders on your mac, not in some sort of simulated main bundle/docs directory sandbox.

In order to get a static file from your main bundle you must create a path starting from [NSBundle mainBundle] and add path components onto it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top