Objective-C: what is personal and what is not?

Why do people use

@interface ViewController : UIViewController 
{
@private
    UIButton* button_;
}

@ private ads in public headers? Declaring a variable inside an implementation gives the same result, doesn't it? It seems strange to me, I thought that the public heading should contain only public members. What to do with protected members?

@implementation ViewController
    UIButton* button_;
@end

The only difference I know about is that this variable is visible only inside the current compilation unit (.m file, right?)

Is the same true for methods? I could compile everything with the correct ordering of methods or forward declarations. Why do people want to declare categories for private methods? Only for testing?

+3
source share
4 answers

@implementation , . @interface.

@interface , , .

+7

, , "" , , .

Cocoa ( ), , Apple .

Apple , , . =)

FYI: .

+4

?

, . , .

. ? ?

- . , C.

+3

@private iVars.

ivars : - id iShouldNotDoThis = foo->bar;

@private , ivar .

id thisIsBetter = [foo bar];

.

0

Source: https://habr.com/ru/post/1720283/


All Articles