Re: Compile warnings according to method order
Re: Compile warnings according to method order
- Subject: Re: Compile warnings according to method order
- From: Wincent Colaiuta <email@hidden>
- Date: Fri, 10 Aug 2007 11:09:12 +0200
El 10/8/2007, a las 10:57, Martin Kyte escribió:
I thought in my simple understanding methods could go in any order.
warnings look like this and the application indeed does not respond
as it should
Building target “RaiseMan” of project “RaiseMan” with configuration
“Debug” — (3 warnings)
'MyDocument' may not respond to '-stopObservingPerson:'
'MyDocument' may not respond to '-startObservingPerson:'
'MyDocument' may not respond to '-startObservingPerson:'
Think of the compiler as reading your source file sequentially from
beginning to end. When it "sees" a message send like this:
[self startObservingPerson:p];
It either has to have seen the method definition already (further up
in the @implementation in the source file), *or* you need to declare
in the @interface (in the header or ".h" file) that your class
responds to that selector so that the compiler can "know" about it
without having seen the actual method implementation yet:
- (void)startObservingPerson:(Person *)person;
So you can solve the problem by carefully ordering your method
implementations or by predeclaring there existence in the @interface
section. As you get more experience and see more code you'll get a
feel for which approach is best.
Cheers,
Wincent
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden