在objective-c中,内存的引用计数一直是一个让人比较头疼的问题。尤其是当引用计数涉及到arc、blocks等等的时候。似乎ARC的出现只是让我们解放了双手,由于底层实现依然依赖引用计数,所以开启ARC后,只有对引用计数机制更加了解,才能避免Cycle Retain、Crash等问题的出现。
但是由于使用ARC可以显著提高编码效率,所以建议尽量启用arc,本文内容也将以arc为主,...
分类:
其他好文 时间:
2014-06-20 12:55:02
阅读次数:
259
如果myeclipse 报如下错误A cycle was detected in the
build path of
project如果我们的项目包含多个工程(project),而它们之间又是循环引用的关系,那么Eclipse在编译时会抛出如下一个错误信息:“A cycle
was detected...
分类:
编程语言 时间:
2014-06-20 08:57:36
阅读次数:
525
1 child->retain();//引用计数+12 3
child->removeFromParent(); 4 5 root->addChild();6 7 child->release();
//引用计数-1需要注意的是retain()和release(),如果在卸载节点前不调用retain...
分类:
其他好文 时间:
2014-06-10 08:48:48
阅读次数:
231
1.栈放局部变量(代码结束就释放,系统自动回收)堆放对象(动态分配)2.每个对象里分配4个字节的存储空间放 引用计数器
当引用计数器值为0时对象占用的内存自动被回收自动回收,引用计数器的初始值是1.3.retain 引用计数器+1
release引用计数器-14.可以给对象发送(调用)retain....
分类:
移动开发 时间:
2014-06-09 18:39:06
阅读次数:
304
脏数据检查 != 轮询检查更新谈起angular的脏检查机制(dirty-checking),
常见的误解就是认为: ng是定时轮询去检查model是否变更。其实,ng只有在指定事件触发后,才进入$digest cycle:
DOM事件,譬如用户输入文本,点击按钮等。(ng-click)XHR响应事...
分类:
其他好文 时间:
2014-06-09 16:26:40
阅读次数:
223
Given a linked list, determine if it has a
cycle in it.Follow up:Can you solve it without using extra
space?求链表是否有环的问题,要考虑链表为空的情况,定义一个快指针和一个慢指针,如果快指针和...
分类:
其他好文 时间:
2014-06-02 08:05:16
阅读次数:
255
Given a linked list, return the node where the
cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it
without using extra space?借用博...
分类:
其他好文 时间:
2014-06-02 07:32:33
阅读次数:
291
如果你在工作中需要使用到线程,或是需要在多线程环境下编程,那么了解线程的生命周期(Life Cycle of Thread)以及线程的状态(Thread States)是很有必要的。
正如我们在上一篇文章中了解到的,通过实现Runnable接口或是继承Thread类,我们可以创建一个Java线程类。如果想要启动线程,我们需要创建一个线程类,然后调用它的start()方法来执行run()中...
分类:
编程语言 时间:
2014-06-02 07:07:17
阅读次数:
288
UILabel:常用属性@property(nonatomic,copy) NSString
*text; // default is nil@property(nonatomic,retain) UIFont *font; // default
is...
分类:
移动开发 时间:
2014-06-02 00:03:51
阅读次数:
432
Given a linked list, return the node where the
cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it
without using extra space?/**...
分类:
其他好文 时间:
2014-05-30 15:59:56
阅读次数:
249