Search code examples
objective-cxcodexcode4

XCode - Creating method stubs automatically?


Is it possible to get xcode to generate the method stubs for the methods that you define in your header file? I'm not talking about protocol methods but your own custom methods in your class.

Cheers


Solution

  • I believe Xcode does not have a command to generate stubs for all (or all unimplemented) methods. However, you can have Xcode generate at least the method signature per method.

    If you define, for example, the following method declarations:

    - (void)aVoidMethod;
    - (int)aMethodReturningInt;
    - (CGSize)sizeOfSomething;
    
    + (void)classMethod;
    + (NSString *)stringClassMethod;
    

    you can generate the method signatures by putting the appropriate sign (+/-) [I forgot the term :) ] plus the first few characters per method.

    For example:

    • Type - av (case insensitive) and CodeSense will automatically (most likely) choose - (void)aVoidMethod
    • + cl to generate method signature for + (void)classMethod
    • and so on. This also works for methods with any number of parameters.