Voloda2
Voloda2

Reputation: 12607

XCode autocompletion: Is it possible to suggest "NSString" when I typed "NSS"?

XCode suggest me "NSSet" when I typed "NSS". It is not very good for me. I use NSString quite often.
Is it possible to suggest "NSString" when I typed "NSS"?

Upvotes: 4

Views: 865

Answers (3)

Filip Radelic
Filip Radelic

Reputation: 26683

Type NSString into the editor, select that and drag it with your mouse to Code Snippet Library (⌃⌥⌘2 if not open), then set its completion shortcut to something not used by Xcode, like "foo".

custom code snippet

Now every time you want to use NSString just type foo and Xcode will offer to auto-complete with NSString. It requires some time to get used to typing something else just like with macro Srikar suggested, but it doesn't add anything new to code itself.

BTW, related comic: https://i.sstatic.net/9tcxD.png

Upvotes: 6

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73588

Yes I know this is really irritating. I use NSString way more often than NSSet & apparently xCode does not take frequency of usage & no ranking of auto-suggest thereof.

I used to use one way to circumvent through this. Its kind of a hack, but as programmers without hacks where are we ;)

I used to create macros. So you could create one like so -

#define xNSString NSString

This way xCode auto-suggest is morphed into suggesting what you need.

Upvotes: 1

Yuji
Yuji

Reputation: 34185

I don't know any direct way to affect the first-shown suggestion.

However, you can always choose from the many other selections shown, or even easier, just type "NSSt".

Upvotes: 1

Related Questions