On Nov 7, 2008, at 1:12 PM, Gustavo Pizano wrote:
While reading about Objective-C, I'm doing some simple exercises, to get familiar with the language. Now I'm "declaring" my methods in the header file (.h) , I was wondering what will happen if in one header file I have a lot of methods declaration?... will I have to copy or retype them to the implementation file (.m)?,
If you type them into the header file first, then you just have the full signatures. Copy them all into the .m file, and then replace the ; at the end of the declaration with { }, and then start typing your definitions. Pretty quick.
It's really no different from how you have to develop anything in C-based languages -- you need to do the same thing for C functions, for instance, or C++ classes and member functions (with some exceptions).
However, if you're only using methods in a class in the class implementation itself, so no one else has to see them, you don't have to declare the methods at all. Just define them above where they're used in the rest of the class.
There are other variations, too, but I won't try to get too complex for now.
So I was reading and I founf that Xcode has some Auto Completion feature which allows me to generate the method code in the (.m) file based on the header file, the point is that I can't figure it out how to do such a thing. If you can help me out I will appreciate it.
Autocompletion is really geared towards helping you type in usages of your methods, not definitions of them.
Here's an example:
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
}
- (int)importantNumber;
@end
@implementation MyClass
- (void)aMethod {
int a = [self importantNumber
}
@end
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden