ITeye博客

我的博客

mirthor · 共 2 篇文章

iOS问题研究之一:应该使用 instance variable还是property

JOHN GALLAGHER在博客里面说,多多建议使用property而很少使用ivar。原因有property更有利于debug和log,但是针对于performance来说,property要优于ivar,主要是ivar在get或是set方法中,调用objc_msgSend将函数名字存到寄存器中,而ivar则直接使用立即数放在寄存器直接操作,但这两种方式都是纳秒级别的,影响很小。所以为了便于log和debug,还是尽可能的使用property。 from: http://blog.bignerdranch.com/4005-should-i-use-a-property-or-an-in…

2014-02-14 14:55 · iOS问题研究 · 评论(0)

iOS性能优化之一:在Objective-C中遍历集合的性能

When enumerating an NSArray: Use for (id object in array) if enumerating forwards. Use for (id object in ) if enumerating backwards. Use for (NSInteger i = 0; i < count; i++) if you need to know the index value, or need to modify the array. Try if your code might benefit from parallel execution. Wh…

2014-02-13 14:51 · iOS性能优化 · 评论(0)