1. 想知道生成什么代码可以clang -rewrite-objc xxx.m (代码错了,判断放循环内,具体自己跑下命令看看)
2. 有官方例子:EnumerationSample(https://developer.apple.com/library/content/samplecode/FastEnumerationSample/Introduction/Intro.html)例子中提到:
“state->mutationsPtr MUST NOT be NULL and SHOULD NOT be set to self.”,然而你就是 set to self
3. 代码有bug:
// 更新extra[0],使其指向下一个节点
if(currentNode)
state->extra[0] = (long)currentNode->next;
改为:
// 更新extra[0],使其指向下一个节点
if(currentNode)
state->extra[0] = (long)currentNode->next;
else
state->extra[0] = 0;
实现快速枚举 NSFastEnumeration基础知识 快速枚举有两个优点。一是,实现快速枚举后,你可以直接使用for/in语法遍历你的对象。二是,如果将快速枚举实现得很好,会大大提高遍历的速度。实现快速枚举,很简单。只...