How to format objective-c block with clang-format?

后端 未结 2 760
野的像风
野的像风 2021-02-20 02:18

I have the following code, for example:

[cardRegistrationVC setCancelBlock:^{
  [weakSelf.navigationController popViewControllerAnimated:YES];
}];
相关标签:
2条回答
  • 2021-02-20 02:30

    Finally I ended up writing blocks like this:

    [cardRegistrationVC setCancelBlock:^{   
      [weakSelf.navigationController popViewControllerAnimated:YES];
    
    }];
    

    Empty line at the end works ok. Or you have to disable column limit:

    #ColumnLimit: 120
    
    0 讨论(0)
  • 2021-02-20 02:51

    Just add this to the setting file(.clang-format).

    ObjCBlockIndentWidth: 4
    

    Then the block will like this.

     [cardRegistrationVC setCancelBlock:^{
         [weakSelf.navigationController popViewControllerAnimated:YES];
     }];
    

    Hope help you.

    At the same time I would like add :

    UseTab: Never
    IndentWidth: 4
    
    0 讨论(0)
提交回复
热议问题