Mailing Lists: Apple Mailing Lists

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

Compile warnings according to method order



Hi Guys
A question from a beginner.
I am working through Aaron Hillegas's book and have just got the first stages of a cocoa document based application running. In order to acheive undo and redo functionality it uses key value observing. The project compiles with no errors and runs correctly when I write


@implementation MyDocument
- (id)init
{
    ..stuff
}

- (void)startObservingPerson:(Person *)person
{
	[person addObserver:self
			 forKeyPath:@"personName"
				options:NSKeyValueObservingOptionOld
				context:NULL];
	
	[person addObserver:self
			 forKeyPath:@"expectedRaise"
				options:NSKeyValueObservingOptionOld
				context:NULL];
	
}

- (void)stopObservingPerson:(Person *)person
{
	[person removeObserver:self forKeyPath:@"personName"];
	[person removeObserver:self forKeyPath:@"expectedRaise"];
}

// . . . . . . . . then the rest of the code

but not when

- (void)startObservingPerson:(Person *)person
{
	...... etc.......
}

- (void)stopObservingPerson:(Person *)person
{
 .... etc....
}

is placed after methods with
[self startObservingPerson:p];
or
[self stopObservingPerson:person];

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:'

Happy for contradiction

Cheers Martin

Martin Kyte
Electronics Workshop
MRC Laboratory of Molecular Biology
Hills Road, Cambridge, CB2 2QH
Tel 01223 252975
email@hidden




_______________________________________________

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


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.