摘要: [[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning) withObject:nil afterDelay:20] 阅读全文
posted @ 2015-09-21 16:22 Kalou 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 今天在看多线程同步时,突然想到了单例的同步问题。自从dispatch_once出现后,我们创建单例非常简单且安全:1 static dispatch_once_t pred;2 static SingleObject *sharedObject = nil;3 4 dispatch_once... 阅读全文
posted @ 2015-03-12 19:04 Kalou 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 最近开是做新项目,准备尝试使用ARC,记录遇到的一些问题。ARC是编译器特性,所以要求Xcode的最低版本为4.2,iOS4以上(注意weak是ios4以上才有的,ios4中只能使用__unsafe_unretained)。ARC的规则:不能调用dealloc方法(可以重写,做一些清除操作,例如de... 阅读全文
posted @ 2014-08-12 21:00 Kalou 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 简单地说,纹理就是矩形的数据数组。例如,颜色数据,亮度数据,颜色和alpha数据。纹理数组中的单个值被称为纹理单元(texel)。OpenGL 2.0 及其以上版本的OpenGL实现,纹理可以是任意大小。 阅读全文
posted @ 2014-07-01 16:24 Kalou 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Class1 typedef struct objc_class *Class; 1 struct objc_class { 2 Class isa OBJC_ISA_AVAILABILITY; 3 4 #if !__OBJC2__ 5 Class super_class ... 阅读全文
posted @ 2014-04-30 17:09 Kalou 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 1 #ifdef DEBUG2 NSLog(@"Cell recursive description:\n\n%@\n\n", [cell performSelector:@selector(recursiveDescription)]);3 #endif这是个私有方法 阅读全文
posted @ 2014-04-28 15:48 Kalou 阅读(158) 评论(0) 推荐(0) 编辑
摘要: NSObject是一切OC类的基类,所以我们必须对NSObject所有的方法有一个清楚的认识。+ (void)load;当类或者分类被加入到runtime时,load方法会被调用,也就是说在main循环开始前load方法就已经被调用。(当类被加载到进程的address space时,runtime就... 阅读全文
posted @ 2014-03-26 12:20 Kalou 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 1.对于autorelease的理解 Each thread in a Cocoa application maintains its own stack of autorelease pool blocks.(Advanced Memory Management Programming Guide:Using Autorelease Pool Blocks) 通过这句话,我们可以看出autorelease pool 是栈的形式,andautorelease pool blocks can be nested主线程中也有自己的autorelease pool,这又牵扯出run loop。实.. 阅读全文
posted @ 2014-03-01 16:20 Kalou 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1.GLProgram--加载vertex和fragment的shader。 好处是完全将shader模块的加载过程独立出来。 学习:每个函数处理一件事,且函数的粒度刚好 在glLinkProgram后就可以将shader给清除掉 输出shader和program的log也值得借鉴2.G... 阅读全文
posted @ 2014-02-10 16:01 Kalou 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 以下代码会引起死锁 1 dispatch_block_t block = ^{ 2 for (int i = 0; i < 100; i++) { 3 NSLog(@"dispatch_sync:%d", i); 4 } 5 }; 6 7 dispatch_queue_t queue = dispatch_queue_create("FIFO.QUEQE", 0); 8 dispatch_async(queue, block); 9 10 NSLog(@"finish dispatch_asyn... 阅读全文
posted @ 2013-09-02 13:34 Kalou 阅读(422) 评论(0) 推荐(0) 编辑