Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Xcode autocomplete @property

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

like image 464
Shimi Bitton Avatar asked Dec 12 '22 17:12

Shimi Bitton


2 Answers

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".

like image 106
Martin R Avatar answered Dec 15 '22 00:12

Martin R


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

like image 30
Anoop Vaidya Avatar answered Dec 14 '22 23:12

Anoop Vaidya