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.
Asked
Active
Viewed 1,966 times
2
![](../../users/profiles/668844.webp)
champak256
- 115
- 1
- 10
1 Answers
3
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.
![](../../users/profiles/588809.webp)
Max
- 16,501
- 4
- 41
- 57
-
Thanks this was very helpful. – champak256 Mar 28 '11 at 10:29