Thursday, 15 September 2011

iphone - Using self in method call -


When the property / synthesize for UITableView, UIButton, etc. is being used, the method on that variable is included in the call should be there? Using UITableView as an example is the difference between [self.myTableView visibleCells] and [myTableView visibleCells] ? Or [self.myImage setImage: ...] and [myImage setImage: ...] ?

I have seen that Apple code uses the self (bubble level) and the first iPhone development of books that do not use themselves, I want to understand it better, especially since in your UIScrollView method call Using the self has caused irregular / buggy scroll behavior because using self.myTableView is another way of saying

< Div class = "post-text" itemprop = "text" [self myTableView] (This can also be done with [self set MyTableView: ...]; If an assignment is used in the statement) In other words, you are executing a method. Using

myTableView directly accesses the instance variable.

Personally, I usually prefer to use the pre-method because it usually frees me from memory management manually and gives me the benefit of KVO information. However, the additional method is the minuscule overhead of the call, which you may wish to avoid.

Which style you prefer to use, depends on you, and its benefits and disadvantages in every way.


No comments:

Post a Comment