摘要:
1. 不要阻塞主线程不管在进行iOS还是OS X开发中,主线程都只应该处理用户交互和界面布局,好的程序通常能够随时快速响应用户的操作,所以CPU密集型或者会阻塞线程的代码应该在其他位置去执行,我指的是其他线程。2. 在后台线程中执行为了不阻塞主线程,我们应该把更多的操作放到后台中去执行,只有在不得不在主线程中执行时(更新UI等)才回到主线程,GCD是最适合这种线程之间切换的://Main Threaddispatch_queue_t queue;queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispa 阅读全文
随笔分类 - 设计模式
Singleton Pattern in Objective-C
2010-10-27 19:58 by Tracy E, 517 阅读, 收藏,
摘要:
Creating a Singleton InstanceA singleton object acts as a kind of control center, directing or coordinating the services of the class. Your class should generate a singleton instance rather than multiple instances when there is conceptually only one instance (as with, for example, NSWorkspace). You 阅读全文
浙公网安备 33010602011771号