是否有方便的快捷方式/工作流来插入方括号以在XCode中发送消息/调用方法?

mav*_*ein 2 xcode objective-c

我是新的Objective C开发,我的工作流程无法发送消息.为了调用方法,java i会输入以下内容:

obj
// .. i am thinking about what to do... call a method!
obj.
// autocompletion pops up
obj.someMethod()
Run Code Online (Sandbox Code Playgroud)

XCode中的工作流程目前对我来说不太方便.目前,如果经常看起来像这样:

obj
// .. i am thinking about what to do... send a message!
obj //damn i need to have the bracket at the beginning
// and jumping to the beginning of the line with cmd+arrow ignores indentation!
[obj // now i need the cursor at the end of the line
[obj someMessage //now i have to insert the bracket myself :-(
[obj someMessage]
Run Code Online (Sandbox Code Playgroud)

如果我想链接消息,这会变得更糟[[obj someMessage] someOtherMessage].

我知道如果我从一个括号开始工作流程会更好,但通常我没有意识到,直到键入我需要一个消息而不是一个属性(这也无助于链接).是否有任何捷径可以让我的生活更轻松,例如用括号包裹一条线?

我希望我能以一种可以理解的方式表达我的问题.:-)

Dav*_*ist 6

添加结束括号时,Xcode会插入左括号(|在我的示例中为光标).

Class|
// I am thinking about what to do... send a message!
Class alloc|
// now lets add the closing bracket
Class alloc]|
// opening bracket is inserted (cursor remains at end)
[Class alloc]|
// now I want to init as well
[Class alloc] init|
// and add closing bracket
[Class alloc] init]|
// opening bracket is inserted (cursor remains at end)
[[Class alloc] init]|
// done. let's just add the semi-colon
[[Class alloc] init];|
Run Code Online (Sandbox Code Playgroud)