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
Post a Comment