Article:
 |
|
Creating a Color Meter Using Cocoa
|
| Subject: |
|
Color Meter compiling problems |
| Date: |
|
2003-07-06 11:02:48 |
| From: |
|
anonymous2
|
|
|
|
This code won´t compile 15 errors can anyone help?
#import <Cocoa/Cocoa.h>
@interface Controller : NSObject
{
IBOutlet id alphaField;
IBOutlet id alphaSlider;
IBOutlet id blueField;
IBOutlet id blueSlider;
IBOutlet id colorWell;
IBOutlet id greenField;
IBOutlet id greenSlider;
IBOutlet id redField;
IBOutlet id redSlider;
float redValue;
float greenValue;
float blueValue;
float alphaValue;
}
- (IBAction)setAlpha:(id)sender;
{
alphaValue = [ sender floatValue];
[alphaField setFloatValue:alphaValue];
[alphaSlider setFloatValue:alphaValue];
[self updateColor];
}
- (IBAction)setBlue:(id)sender
{
blueValue = [sender floatValue];
[blueField setFloatValue:blueValue];
[blueSlider setFloatValue:blueValue];
[self updateColor];
}
- (IBAction)setGreen:(id)sender
{
greenValue = [sender floatValue];
[greenField setFloatValue:greenValue];
[greenSlider setFloatValue:greenValue];
[ self updateColor];
}
- (IBAction)setRed:(id)sender
{
redValue = [sender floatValue];
[redField setFloatValue:redValue];
[redSlider setFloatValue:redValue];
[ self updateColor];
}
- (void)updateColor
{
NSColor *aColor = [ NSColor colorWithCalibratedRed:redValue green:greenValue blue:blueValue alpha:alphaValue];
[colorWell setColor:aColor];
}
@end
|
Showing messages 1 through 1 of 1.
-
Color Meter compiling problems
2004-01-02 16:49:48
anonymous2
[View]
- (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.