How to make Xcode autocomplete @property

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

+4
source share
3 answers

As mentioned in an Alladinian comment, you can achieve this with the special "code snippet" in Xcode. To identify a piece of code, first enter the text in the source file, for example

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

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

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

enter image description here

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

enter image description here

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

enter image description here

Select the code fragment and it will be inserted into the source file:

enter image description here

You can use the tab to go to "type" and "name".

+10
source

Check the box displayed in RedBox, your Xcode completion will work

enter image description here

EDIT:

If you can see in the .m file, then of course your .h contains some syntax error. Due to this error, the LLVM compiler shows a signal for correction and your autocomplete does not work.

EDIT 2:

According to your comment, when typing @prop autocomplete doesn't display erty(,) even in Xcode4.6

enter image description here

+2
source

@property is not autocomplete. However, @synthesize does. See this question:

Xcode [ESC] cannot automatically complete property in .m file

0
source

All Articles