I have a plist (array of dictionaries) with 20 items, each of the 20 dictionaries having a 'code' and 'text'; each text averages 1K bytes. The class that uses the text will use 1 of the 20, based on the 'code'. The text doesn't change so I'm keeping it in the bundle.
I'd like to know if I'm doing this as efficiently as possible, basically reading in 20K of data for a second, using what I need and releasing all but the 1K that I use.
I have 2 ivars without properties:
NSMutableArray *explanation;
UITextView *textView;
The textView is in a UITableViewCell and from the cellForRowAtIndexPath I call [self retrieveExplanation]. I load the textView from within retrieveExplanation rather than returning an NSString, to save the additional NSString memory allocation.
-(void) retrieveExplanation {
explanation = [[NSMutableArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"explanation"ofType:@"plist"]];
textView.text = [[explanation objectAtIndex:[self.itemNumber intValue] - 1] objectForKey:@"text"];
[explanation release];
}
Can this be more efficient? Should I consider using 20 plists or text files?
Thanks