Xcode 9 code completion not working for #interface #implemetation - xcode

When I input #interface or #implemetation, there is no code completion. Others' code completion work fine. Is that function removed or it is a bug?

I've found the answer is that input interface or implemetation without #, search the list of auto completion and select "Objective-C Class Interface/Implemetation" and that is it.
If you don't see that one in the list, just page down until you find it that start with a {} icon. If you've used it once, it'll be at the first place in the auto completion list next time.

Related

Xcode turn off code completion for NSObject

Is there a way to modify Xcode's (6.4/7.x beta whatever) code completion in such a way that neither the methods nor the properties of NSObject in a subclass of it are shown? I think, I don't use them frequently and it is pretty annoying when searching for another function whose name I can only slightly guess and then have to scroll through all the unnessecary suggestions coming from NSObject.
Thanks for your help
Not sure that its possible to adjust autocomplete only for NSObject and descendants (of course it might be the way), but there is another nice tool I'm using:
https://github.com/FuzzyAutocomplete/FuzzyAutocompletePlugin
It won't solve a problem of unnecessary suggestions you see, but
it's easier to add and remove from Xcode (comparing to manually internal Xcode files edit)
it solves a problem of "searching for another function whose name
I can only slightly guess"

Xcode "OmniSearch" in autocomplete

In other IDEs during code complete, I could type any char/word inside the method (doesn't have to be in the order it apears) and it will filter out those methods.
So far, it seems like in Xcode, I'll have to type out the name of the method from beginning to end in order, else the autocomplete popup disappears.
Is there any way to get this "omnisearch" feature in Xcode?
XCode's auto complete does not support that.

Function name not appearing in xcode 4.3.3 breadcrumbs pulldown

I have dozens of functions across many .m files that appropriately show in the pulldown menu on the xcode bread crumbs bar. However, last night, I added a new function to my code, but it absolutely won't show up in the pulldown list. The function before it appears. The function after it appears. Pragma marks before and after it appear. I've restarted Xcode several times. After defining the function in the .h, Xcode autofills the function name in the .m. The code in the function works fine. It just won't appear in the breadcrumbs pulldown.
I'm getting around it right now by adding a pragma mark right before the function starts. But, does anyone have any suggestions on why it's not showing in the pulldown and what can be done about it?
Spr.h
-(void) wCheck:(NSMutableArray *)CO lat:(double)target_lat long:(double)target_long;
Spr.m
#pragma mark wCheck <-- this works
-(void) wCheck:(NSMutableArray *)CO lat:(double)target_lat long:(double)target_long
{
//the code in here works fine.
}
Try forcing re-indexing of your project. Open Organizer -> Projects, select your project, delete its derived data, restart Xcode, wait for it to complete indexing.
re-indexing didn't help. I'm just sticking with the workaround of adding a #pragma mark right before the function name.

Remove all NSLogs in Xcode at once

Am currently creating a demo drawing and image editing app just for a practice. Have created few custom views and doing my drawings using draw rect. Thing is i keep writing NSLogs to check my points and contents of other objects frequently and i dont remove many of them, since i need them again and again. But observing that the logs are eating up processing time and making some of the drawing process laggy.
My question is, is there any method in xcode to remove all NSlogs at once while launching the app and add them again while testing.
Do something like this...
Click Command+Shift+F
Select Replace
And replace NSLog with //NSLog
Not so good solution, but still works! :)
Hi One method that i came to know is using the Find and replace option in xcode.
ie. say for eg you need to remove all NSLogs you have written in your entire project.
Find for the NSLog keyword in whole project (cmd+shift+F), then replace it with //NSLog. This would comment out all the NSLogs you have written.
When you need to uncomment the logs just do the opposite.
ie Find for the //NSLog keyword in whole project (cmd+shift+F), then replace it with NSLog. This would uncomment out all the NSLogs you have written and they print in the console again.
You can do this for particular files also by using just (cmd+F) instead of (cmd+shift+F)..
But not sure if xcode actually has a proper method to do this.
found one more good way of doing it, by defining your custom NSLog, using a macro like this:
MYLog(#"Count of student array-->%d",[studentArray count]);
And in your app-prefix.h file, which holds the common headers for all your files in the project define the 'MYLog' macro this way:-
#ifdef DEBUG
#define MYLog(f, ...) NSLog( #"<%#:(%d)> %#",[[NSString stringWithUTF8String:_FILE _] lastPathComponent], _LINE _, [NSString stringWithFormat:(f), ##_VA_ARGS _] )
#else
#define MYLog(f, ...)
#endif
So when you need to test, put your project in debug mode and when you need to run without the logs put your project in release mode. Simple..
ps FILE AND LINE are macros executed py the preprocessor to print the file name and line no in which the log is present. Try it out..

Xcode method navigation

In Xcode 4, I can press Ctrl-6 to get a list of all the methods in the current file.
The problem is, if I have private methods declared at the top of my implementation file, say:
#interface Foo ()
-(void)tap:(id)sender;
#end
#implementation Foo
...
-(void)tap:(id)sender
{
...
}
then starting to type "tap" while the method list is visible will just take me to the declaration, since it comes first in the file, when what I really want is the implementation.
Is there any way to exclude these declarations from the method list or do I need to resort to separate Foo.h and Foo+Private.h headers?
Thanks!
You dont need to declare you private methods and you wont get a warning by default anymore. So one options is not to declare a prototype at all.
Otherwise as curthipster mentioned ctrl-6 is a good shortcut. I use this all the time (no mouse needed):
Press ctrl-6
Type the first few letter of the method name (or a word it contains and you dont even have to spell it spot on, the search filter is very good!)
Tap down until the method is selected.
Tap enter
Alternativly open the assistant with cmd-alt enter (to close use cmd-enter, see more shortcuts here). You can make the assistant editor look at the same file, so it has one part of view at the top and one at the bottom for example.
I don't think there's a way to exclude the method declarations from the Document Items popup.
If you get in the habit of using code folding, however, you might not rely so much on that popup to navigate your source code. There are commands for folding both methods and comment blocks, and you can fold all methods with one quick shortcut (command-option-shift-left arrow to fold, -right arrow to unfold by default, though you can of course customize the keys). See the Editor->Code Folding submenu for a complete list of related commands.
When you fold all comments and methods in a .m file, almost all you're left with is a list of methods that's makes it easy to find what you're looking for. You can then unfold just that method or all methods with another keystroke. It's a little strange to see all your code disappear when you first start using folding, but it's a very handy feature.
Usually, it's better to add a named category for the private methods:
#import "Foo.h"
#interface Foo( Private )
- ( void )tap: ( id )sender;
#end
#implementation Foo( Private )
- ( void )tap: ( id )sender
{}
#end
#implementation Foo
...
#end
Then you'll see each one. It may not answer your question, but at least you'll see your method.
One thing is also to organize your methods with mark pragmas:
#pragma mark - Private methods
May help you to navigate through the completion dialog...
Hope this helps...

Resources