1
我知道如果我們使用@synthesize編譯器在hadder文件中定義屬性的基礎上創建getter和setter ..但是如果我們想創建自己的getters和setter,我們會做什麼? 我們如何創造我們自己的getter和stters這個哪個getters和setter執行得更快?
@synthesize navcontroller
@屬性(非原子,保留)的UINavigationController * navcontroller;
如果我們創建自己的getter和setter方法執行速度更快或@synthesize getter和setter方法瓶坯更快,爲什麼?......
大多數情況下你不會注意到巨大的差異。畢竟你做同樣的事情,只是手動而不是自動。 – futureelite7
參考[這個問題](http://stackoverflow.com/questions/4141189/objective-c-custom-getter-setter)。無論它們是如何創建的,性能增益或損失最多都是微不足道的。花時間在其他領域進行優化。 – FreeAsInBeer
這個[示例](http://useyourloaf.com/blog/2011/2/8/understanding-your-objective-c-self.html)可能會很好地描述你,getter和setter的性能取決於寫作的代碼 –