Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

How come whenever I have to use awakeFromNib protocol I have to put it in this format?

-(void)awakeFromNib

What is the need for -(void)?

like image 900
nambvarun Avatar asked Nov 28 '22 06:11

nambvarun


1 Answers

The -(void) is used in the declaration of the method. Presumably, you are defining it for someone else to call, rather than calling it yourself.

The - sign indicates that the method is an instance method, as opposed to a class method. It requires an object to call it, and instance variables of the object are available to it inside its definition.

The (void) indicates the return type. This method doesn't return anything, so its result can't be assigned to anything.

like image 168
uncleO Avatar answered Dec 28 '22 05:12

uncleO