iphone - Private properties and methods in Objective-C -


in looking @ 1 of apple's examples, in tableviewcontroller.m, have this:

// private tableviewcontroller properties , methods. @interface tableviewcontroller ()  @property (nonatomic, retain) nsmutablearray* sectioninfoarray; @property (nonatomic, retain) nsindexpath* pinchedindexpath; @property (nonatomic, assign) nsinteger opensectionindex; @property (nonatomic, assign) cgfloat initialpinchheight; ... more properties , methods @end  @implementation tableviewcontroller ... usual stuff 

i'm wondering why put these properties in .m file , how private. seems imports tableviewcontroller.m file can use these properties , methods right? why not use @private in .h file?

what they're doing declaring category on class, since done in .m file, effect methods "invisible".

this doesn't mean methods cannot called outside. due fact there no real privacy in objective c, because we're dealing messages, not method calls. means can send object message if not know if object implements method you're trying call. receiving object determine @ runtime if can handle call, maybe forward it, , make no difference whether method known calling object or not.

this 1 of reasons why possible call private apis , rejected it.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -