Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compile warnings according to method order



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Compile warnings according to method order (From: Martin Kyte <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.