3

This is mainly an advice question, so any pointers are much appreciated.

I have a text file that I would like to draw on when filling UITableViews. I just don't know when I should actually read the file, or even how. Do I use NSFileManager, or NSFileWrapper, or should I roll my own? Will a Object Placeholder be needed in the Nib file?

The idea is to create an "inventory" system that utilizes a navigation-tableView-tabBar combo.

I've tried to figure out something, but after starting and restarting, I realized I should ask for help.

Specs include Xcode4, some basic understanding, and about 13 different trashed projects.

cacau
  • 3,606
  • 3
  • 21
  • 42
GaleDragon
  • 128
  • 3
  • 11

1 Answers1

1

When and how you read the file will depend largely on the file size. If it is a fairly small file, then you can read it synchronously on -(void)viewDidLoad. If it is larger, then you will need to read it asynchronously and display an activity indicator until the read is finished. Here is a simple method for reading a text file into an NSString:

- (NSString *) getTextFromFile:(NSString *)filePath {
   return [NSString stringWithContentsOfFile:filePath usedEncoding:nil error:nil];
}
memmons
  • 40,222
  • 21
  • 149
  • 183