champak256
champak256

Reputation: 115

How to lazy load?

How do you lazy load a NSMutableArray in tableView:didSelectRowAtIndexPath:? I am very new to Objective-C, XCode, and iOS programming, so any help is appreciated.

Upvotes: 2

Views: 1985

Answers (1)

Max
Max

Reputation: 16719

Lazy load means 'loading on demand'. So you perform operation only when it is really necessary, and not beforehand. Say we have method:

-(void) init {
   self = [super init];

   mMyMemberArray = [self loadSomeDataToArray];
}

-(void)  tableView:didSelectRowAtIndexPath: {
   [someObject processData: mMyMemberArray];
}

This is not lazy loading cause we've loaded data beforehand. But this:

-(void)  tableView:didSelectRowAtIndexPath: {
   someObject processData: [self loadSomeDataToArray]];
}

is exactly lazy loading, cause you get data when you really need it.

Upvotes: 3

Related Questions