1
执行用于从手机访问地址簿并保存到本地sqlite3数据库的后台进程。我做了如下。如何运行后台进程/多线程进程,以获得更好的应用程序性能目标c
[self performSelectorInBackground:@selector(syncAddressBookToDB:) withObject:nil];
- (void)syncAddressBookToDB:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// accessing the address book and saving to the database.
GVDBManager *objDB = [GVDBManager getSharedInstance];
[objDB getContactsFromAddBook];
[objDB syncPhoneBookWithVcardsTable];
[pool drain];
}
有没有更好的方法来实现背景/多线程过程来改善我的应用程序的性能。任何人请为我提出更好的解决方案。
为什么?它不够好吗?你已经在另一个线程上工作,如果它运行缓慢,那么你的问题是在运行代码,而不是线程',我希望我很清楚.. –
如果你想多一点控制线程,但不要太复杂,请在此处查看GCD:https://developer.apple.com/library/mac/documentation/performance/reference/gcd_libdispatch_ref/Reference/reference.html – Jack