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-instance-variable/

猜你喜欢

转载自mirthor.iteye.com/blog/2017368