What is the difference between adding pseudo-party Ivars to a class extension or to an @implementation block?

What is the difference between putting pseudo-private instance variables in a class extension inside a .m file or putting them in newly entered @implementation brackets, as shown below?

Are there any consequences, pluses, minuses on one way or another? Is inner2 handled differently than internal3, what should a programmer do? (Of course, there is a difference Mackay talked about, but the question is if you care in practice or not).

// MyClass.m

@interface MyClass () {
    id internal2;
}
@end


@implementation MyClass {
    id internal3;
}

- (void)internalMethod {
    NSLog(@"%@ %@", internal2, internal3);
}

@end

source: http://www.mcubedsw.com/blog/index.php/site/comments/new_objective-c_features/

+5
source share
2 answers

, , ivar @implementation, , @implementation .m( @ ( )). , "private" ivars:

  • MyClass.h: public ivars
  • MyClass + Private.h: - ivars
  • MyClass.m: ivars

, MyClass - UIView. UIView.h - , , UIView + Private.h - "private", Apple , UIView.m , , UIView. .

+9

ivars , , . , - , , , .

+3

All Articles