ios - Do I need to declare a method prior to the first use of the method in same class? -


i new in objective c, , working in c/c++ till now.

in c/c++, if function not know prototype of function, not call function, if in same file. either use header file, or write prototype before using it. like,

void proto(void);  void somefun() {    proto(); //call function  } 

but in objective c, have function in same file, can call without giving prototype. following code compiling correctly.

//calling before declaring/defining, works fine. [self processresponse:responseobject];   -(void)processresponse:(id)responseobject {  } 

can objective c calls functions without knowing prototype if in same class? should prefer?

please note processresponse internal function. not want expose other class.

can objective c calls functions without knowing prototype if in same class?

yes try call it.

what should prefer?

it better declare function in private extention part of implementation file(.m) since dont want expose function other class.

advandtages:

1.other peer can understand method internal

2.other class, no 1 can access it.

in implementation file(.m)

@interface myclass ()  -(void)processresponse:(id)responseobject;  @end  @implementation myclass  @end 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -