Sunday 15 February 2015

Void in Objective-C -



Void in Objective-C -

i learning objective-c , wondering when people when out void in method means method returns nothing. mean? "return" if wasn't void? please help.

void said, word utilize allow compiler know function doesnt homecoming anything, , may omit homecoming statement in function eg

- (void) mymethod { //do here }

where if method has homecoming type, compile error if didnt homecoming of type

- (bool) mymethod { bool x = false; //do homecoming x; }

so here can see, in words "what "return" if wasn't void?" homecoming whatever tell to, homecoming type when declare method needs match returning , thats really.

note can still homecoming in void function, prematurely end functions execution, eg

- (void) mymethod { bool x = false; if(x == false) return; x = true; }

here can see statement x = true never execute, because go if statement , return, end function (and not homecoming anything)

objective-c void

No comments:

Post a Comment