advertisement

Article:
  Creating a Color Meter Using Cocoa
Subject:   Color Meter compiling problems
Date:   2004-01-02 16:49:48
From:   anonymous2
Response to: Color Meter compiling problems

First of all, you do realize that you only "delcare" your methods in Controller.h, and no code goes in that file. The actual code goes in Controller.m (@implementation file). For example, this chunk of code for setAlpha: goes in Controller.m:


- (IBAction)setAlpha:(id)sender
{
alphaValue = [ sender floatValue];
[alphaField setFloatValue:alphaValue];
[alphaSlider setFloatValue:alphaValue];
[self updateColor];
}


Also, make sure that you do not have a semi-colon (;) after your method name in your Controller.m... for example, this is correct:


- (IBAction)setAlpha:(id)sender { ...code... }


and this is incorrect:


- (IBAction)setAlpha:(id)sender; { ...code... }. (Notice the semi-colon after 'sender'.)


It's quite easy to forget to take out the semi-colon if you copy and paste from your .h file to your .m file.


Hope that helps you.