objective c - When do we use self. or [self ] in stringWithFormat? -


when using stringwithformat nsstring in return statement when use self. ; [self ] or instance?

for example, have return [nsstring stringwithformat:@"%@ %@" , self.someinstance or [self someinstance] or someinstance].

self.someinstance equivalent [self someinstance]. former using dot-syntax became available in objective-c 2.0.

it's personal preference option use. suggest being consistent throughout app , use 1 format.

using someinstance on own, without self. or [self ], different , accesses instance variable directly. should avoided outside of init methods.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -