Shimi Bitton
Shimi Bitton

Reputation: 164

How to make Xcode autocomplete @property

How can I make Xcode autocomplete a @property directive? I saw it on someone's Mac.

Upvotes: 4

Views: 1746

Answers (3)

Martin R
Martin R

Reputation: 539765

As Alladinian already mentioned in a comment, you can achieve this with a custom "Code Snippet" in Xcode. To define a code snippet, you first type the text in a source file, for example

@property (nonatomic, strong) <#type#> *<#name#>;

(<#...#> is a special placeholder, so that you can jump to "type" and "name" using the tabulator key later.)

Then you select the entire line, and drag it to the "Code Snippet Library":

enter image description here

Double-click on the new code snippet, and give it a name and a shortcut:

enter image description here

Now, when you type the shortcut, Xcode will offer the completion:

enter image description here

Select your code snippet, and it will be inserted in the source file:

enter image description here

You can use the tabulator to jump to "type" and "name".

Upvotes: 10

Anoop Vaidya
Anoop Vaidya

Reputation: 46543

Check the box shown in RedBox, your XCode autocompletion will work

enter image description here

EDIT:

If you are able to see in .m file, then surely your .h contains some syntax error. Due to that error LLVM compiler shows signal to correct and your autocompletion is not working.

EDIT 2:

As per your comment, while typing @prop the autocompletion does not show erty(,) even in XCode4.6

enter image description here

Upvotes: 2

Jean
Jean

Reputation: 7673

The @property does not auto-complete itself. However, the @synthesize does. See this question:

Xcode [ESC] fail to auto complete the property in .m file

Upvotes: 0

Related Questions