I trying to learn a bit more about Objective-c, and at the moment i'm stuck. I got 4 errors, all the same. "Implicit declaration of function", I googled it but i didn't find a solution.
RadioStation .h
#import <Cocoa/Cocoa.h>
@interface RadioStation : NSObject {
NSString* name;
double frequency;
char band;
}
+(double)minAMFrequency;
+(double)maxAMFrequency;
+(double)minFMFrequency;
+(double)maxFMFrequency;
-(id)initWithName:(NSString*)newName atFrequency:(double)newFrequency withBand:(char)newBand;
-(NSString*)name;
-(double)frequency;
-(char)band;
-(void)setName:(NSString*)newName;
-(void)setFrequency:(double)newFrequency;
-(void)setBand:(char)newBand;
@end
RadioStation .m
#import "RadioStation.h"
@implementation RadioStation
+(double)minAMFrequency{
return 520.0;
};
+(double)maxAMFrequency{
return 1610.0;
};
+(double)minFMFrequency{
return 88.3;
};
+(double)maxFMFrequency{
return 107.9;
};
-(id)initWithName:(NSString*)newName atFrequency:(double)newFrequency withBand:(char)newBand{
self = [super init];
if(self != nil){
name = [newName retain];
band = newBand;
if (band == 'F') {
if (newFrequency > maxFMFrequency()) {
frequency = maxFMFrequency();
}else if (newFrequency < minFMFrequency()) {
frequency = minFMFrequency();
}else {
frequency = newFrequency;
}
}else if (band == 'A') {
if (newFrequency > maxAMFrequency()) {
frequency = maxAMFrequency();
}else if (newFrequency < minAMFrequency()) {
frequency = minAMFrequency();
}else {
frequency = newFrequency;
}
}
}
return self;
}
@end
The lines
if (newFrequency > maxFMFrequency()) {
if (newFrequency < minFMFrequency()) {
if (newFrequency > maxAMFrequency()) {
if (newFrequency < minAMFrequency()) {
all say "Implicit declaration of function"
Thanx in advance, Dietger
These are class methods so you will need to change each of them as follows:
if (newFrequency > [RadioStation maxFMFrequency]) {
if (newFrequency < [RadioStation minFMFrequency]) {
if (newFrequency > [RadioStation maxAMFrequency]) {
if (newFrequency < [RadioStation minAMFrequency]) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With