• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 767
  • Last Modified:

iOS File Not Found Error

Hello Experts,

I am developing an iOS program for iPad. The program performs some simple calculations and in the course of doing so, it reads a text file containing a lookup table (table.txt). It works fine when I run it in XCode using the iPad simulator, but when I run it on my iPad, it gives a “File not found” error. I’m reasonably sure it’s not finding the table.txt file, but I’m not sure how to verify that the table.txt file is being transferred to the iPad as part of the application test installation. I used Xcode’s “Add Files To …” function to make sure the table.txt file was added to the project, and I also visited the Target|Copy Bundle Resources pane to make sure the table.txt file was one of the items in the list.

Curiously, the program reads another data file (page0.psf) supposedly from the same directory without a problem.

I’m an old Windows programmer new to iOS so I’m not sure what I may be doing wrong. Any ideas?
0
efz
Asked:
efz
  • 2
  • 2
2 Solutions
 
Hamidreza VakilianSenior iOS DeveloperCommented:
The first step is to ensure that the file is copied to its correct location on the iDevice.
Download and install this free iOS file system browser, iExplorer:
http://www.macroplant.com/iexplorer/

Run the application; Connect your iDevice; Go to /private/var/mobile/Applications/;
find your application's directory and check whether it exists at where it was supposed to be.
Report the result here for further assistance.
0
 
pgnatyukCommented:
Check the full file name - iOS is a case sensitive file system.
If this file has name table.txt and it's located in the application bundle, you can load it

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"table" ofType:@"txt"];  
if (filePath) {  
    NSString *theText = [NSString stringWithContentsOfFile:filePath];  
    if (theText) {  
    }  
}  

Open in new window

0
 
Hamidreza VakilianSenior iOS DeveloperCommented:
If it was due to a character case mismatch then he would also had faced the issue on iOS simulator.
It's probably because the file does not take place in the supposed path, or a simple path calculation mistake.
0
 
pgnatyukCommented:
Programmer-x: It's not absolutely correct. At least on my Mac do not have the case sensitive system and so on the simulator.
0
 
efzAuthor Commented:
You two are golden. Both were right. Even though I was aware of the case sensitivity issue I had previously placed a mis-capitalized file name on the iPad and later file transfers were not overwriting the file name even though I had corrected it on the Mac. Therefore it was a case senstitivity issue.

However, I could never (ever) have diagnosed this problem without using the iExplorer tool recommended by pgnatyuk. Truly a necessary first step.

Excellent advice.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now