2

我是新的 Objective C 开发人员,我的工作流程发送消息时遇到问题。为了调用一个java方法,我会输入以下内容:

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

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]

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

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

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

4

1 回答 1

7

|当您添加右括号(在我的示例中为光标)时,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];|
于 2013-09-11T11:33:24.157 回答