Question

I don't want to give up before asking, because this is basic functionality in any Java/.Net IDE. The compiler tells me:

Incomplete implementation of class...
Method definition for '-someMethod:' not found

but clicking, right-clicking, praying and Google searching have not gotten me to automatically create a method stub from this. Can Xcode create a method stub for me and take me there?

If not, why might that be (aside from "real programmers enjoy typing")?

Edit: I thought that option-escape basically solved this for me, but it does not. It doesn't seem to be aware of all (any?) of the interfaces my class implements.

Was it helpful?

Solution 4

What the OP (me) is talking about is in Java, where the interface is implicit. However, the case that is the same in Xcode is one where there is NO method yet defined in any interface.

AppCode handles this case, Xcode does not (unless somebody answers this question, but it's been here for a while):

AppCode popover showing method creation

Later: People have answered the question, but Xcode still doesn't do this.

OTHER TIPS

This might be an option to file a feature request to Apple. Typically, I will design my @interface file and then do a copy/paste of the @interface to the @implementation keeping typing to an absolute minimum.

However, it would be nice to be able to click on the warning and have Xcode simply create the method at the botto of the @implementation.

NOTE: it is valid to keep the semicolon after the @implementation

@interface PCStackValue : NSObject <NSCoding, NSCopying>
{
}

- (id) initWithDisplayRadix:(int) newRadix;

@end

@implementation PCStackValue

- (id) initWithDisplayRadix:(int) newRadix;
{
   … do something;
}
@end    

I don't mind this behaviour. For one, the implementation does not necessarily exist as it might be dynamic. I also categorize my code using #pragma mark - MyCategory and want the implementations in specific locations in the source file.

However, I agree - I don't want to type the stub itself.

You can do it per method.
Go to your implementation file and start typing - prefix and hit ESC and you should see valid completions matching the prefix. You must start with typing a - or + for this to work, for instance methods and class methods respectively.

Sometimes you don't know what it is you are to implement! Open the Issue Navigator, and click the disclosure rectangle. There should be a line that says Method declared here. Click on it to see the method that lacks implementation.

What you're looking for doesn't exist. I just use auto-complete (it usually works for me) or copy/paste.

What makes you think Xcode would have a feature just because eclipse has it? Eclipse is ~10 years old, while Xcode is ~23 years old. Any features copied would most likely be in the other direction.

It would make a great feature request however. Perhaps opening the auto-complete menu on an empty line inside @implementation .. @end could give a list of not-yet-implemented methods.

But I'm not sure how well it would work in practice, because of NSObject categories. There might literally be thousands of "not-yet-implemented" methods in the auto-complete menu. But it could at least show some of the most likely ones.

It seems like this compile error/warning would also be a good candidate for the new "Fix It" feature.

Also: learn to type faster :p

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top