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!
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.
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):
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With