如何延迟加载? [英] How to lazy load?
本文介绍了如何延迟加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您如何在tableView:didSelectRowAtIndexPath:
中延迟加载NSMutableArray
?我对Objective-C,XCode和iOS编程非常陌生,因此不胜感激.
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.
推荐答案
延迟加载意味着按需加载".因此,仅在确实必要时才执行操作,而不是事先执行.说我们有方法:
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.
这篇关于如何延迟加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文