Short and useful Objective-C snippets?

前端 未结 9 881
慢半拍i
慢半拍i 2021-01-30 07:17

Since XCode 4, there is now a Code Snippets section which offers the snippets via auto-complete when typing. I\'d be very interested in snippets you all have stored in there. Wh

相关标签:
9条回答
  • 2021-01-30 08:06

    I also have the standard view lifecycle methods in my snippets (which get used daily):

    I use keyboard shortcut vwa for

    - (void) viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear: animated];
    
    
    }
    

    vdl for viewDidLoad etc.

    0 讨论(0)
  • 2021-01-30 08:09

    I’m often adding private class interfaces with class extensions:

    @interface <#ClassName#> ()
    @end
    

    This is to keep the public interface completely free from internal stuff, especially now that we can have purely synthesized properties (example gist).

    0 讨论(0)
  • 2021-01-30 08:11

    While debugging this snippet is really useful. It let you know Class Name, Function Name and you can add your comments also.

    NSLog(@"%s [Line %d] %@ ", __PRETTY_FUNCTION__, __LINE__,<#comment#>);
    
    0 讨论(0)
提交回复
热议问题