Cocoa Objective-C header file question
So I got Aaron Hillegass' new Cocoa Programming book, and I'm working through an example. At one point he shows adding a method to the implementation file, but not to the header file. Here is the method:
- (void)awakeFromNib
{
// stuff to do
}
So I went to the header file and added it in with the other method declarations. It runs fine without that method declared in the header file, and also with it added. I assume he just overlooked telling us to add it, or assumed that we'd know to do it on our own. Do you not need to add methods to the header file that don't return a value? I wouldn't imagine that would be the case. I've done some Java before, but the C header and implementation files are kinda new.
Any help is appreciated.
Thanks
Code:
- (void)awakeFromNib
{
// stuff to do
}
So I went to the header file and added it in with the other method declarations. It runs fine without that method declared in the header file, and also with it added. I assume he just overlooked telling us to add it, or assumed that we'd know to do it on our own. Do you not need to add methods to the header file that don't return a value? I wouldn't imagine that would be the case. I've done some Java before, but the C header and implementation files are kinda new.
Any help is appreciated.
Thanks
Comments
at run time, when you call a message on an object, if the object doesn't really respond to the message, you get a runtime error (which, i'm 50% sure means that the return value of the whole expression is NULL, or some kind of popup happens, or soemthing is spit on the error log [maybe all three, or somethign else similar]). haven't done objective-c in a few months, so i'm a little out of practice.
and repeating the declaration in a subclass, as well as the parent, doesn't hurt anything. even if you dont re-implement the method in the subclass, it will only reiterate to the compiler that the method exists somewhere in the subclass' hierarchy.
Now I guess they should have banned me rather than just shut off posting priviledges, because kickaha and Amorph definitely aren't going to like being called to task when they thought they had it all ignored *cough* *cough* I mean under control. Just a couple o' tools.
Don't worry, as soon as my work resetting my posts is done I'll disappear forever.
Thanks, question answered.
Now I guess they should have banned me rather than just shut off posting priviledges, because kickaha and Amorph definitely aren't going to like being called to task when they thought they had it all ignored *cough* *cough* I mean under control. Just a couple o' tools.
Don't worry, as soon as my work resetting my posts is done I'll disappear forever.