What does "- (void)" mean in the declaration of this function? `- (invalid) awakeFromNib`

As always, when I need to use the awakeFromNib protocol, should I put it in this format?

-(void)awakeFromNib

What is the need - (void)?

+3
source share
4 answers

The method declaration is used -(void). Presumably, you define it for someone else to call, rather than call it yourself.

The sign -indicates that the method is an instance method, unlike a class method. This requires the object to call it, and instance variables of the object are accessible to it within its definition.

(void) . , .

+20

, , , "Math"

, "".

-(int)calculate {
2+2;
return 2+2;
}

" ", 2 + 2 , 4.

-(void)calculate {
2+2;
}

, 2 + 2, , .

+7

, void - , C Objective-C.

+2

(void) indicates the type of return - in this case, void means that it returns nothing.

If it were instead of - (int) awakeFromNib, you expected to return an integer. The return value (if any) must be explained in the documentation.

0
source

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


All Articles