数据存储、排序
2017-11-28 本文已影响0人
lifeLL
在项目遇到这么一个场景,从SQL数据库取出数据,按声母排序,耗时间比较长,固做了以下优化:
开始直接在viewDidLoad调用
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
_dataRecentContact = [FeedUserListHelper getUserListContactDataBy:[FeedRecentContactListSQL lookFeedRecentContactList]];
//关注列表
_dataFocus = [KLFeedNoteNameSQL lookFeedMerchantFocusList];
_dataHotUserArray = [FeedHotUserListSQL lookFeedHotUserList];
_rowArray = [FeedUserListHelper getUserListDataBy:_dataFocus];
_letterArray = [FeedUserListHelper getUserListSectionBy:[_rowArray mutableCopy]];
});
但是需要@的入口太多,到处都需要设置属性,后来觉得应该写在单例好了,放在UITabBarController调用
func getDataForFeedAltetUserList() {
dataRecentContact = FeedUserListHelper.getUserListContactDataBy(FeedRecentContactListSQL.lookFeedRecentContactList()) as NSMutableArray
dataFocus = KLFeedNoteNameSQL.lookFeedMerchantFocusList()
dataHotUserArray = FeedHotUserListSQL.lookFeedHotUserList()
rowArray = FeedUserListHelper.getUserListDataBy(getDataFocus())
letterArray = FeedUserListHelper.getUserListSectionBy(getRowArray().mutableCopy() as! NSMutableArray)
}