Reading Text Files on iPhone

This is mainly a Soviet question, so any pointers are very much appreciated.

I have a text file that I would like to use when filling out UITableViews. I just don't know when I should really read the file or even how. Should I use NSFileManageror NSFileWrapper, or should I use it myself? Is an object placeholder in a Nib file required?

The idea is to create an “inventory” system that uses a combination of navigation-tableView-tabBar.

I tried to find out something, but after starting and restarting, I realized that I had to ask for help.

Specifications include Xcode4, some basic understanding, and about 13 different projects broken down.

+3
source share
1 answer

When and how you read the file, the size of the file will largely depend. If this is a fairly small file, you can read it synchronously on -(void)viewDidLoad. If it is larger, you will need to read it asynchronously and display an activity indicator until the reading is complete. Here is an easy way to read a text file in NSString:

- (NSString *) getTextFromFile:(NSString *)filePath {
   return [NSString stringWithContentsOfFile:filePath usedEncoding:nil error:nil];
}
+1
source

All Articles