I want to call a class method from an instance method to use its return value.
This is my class method
+(double) minFMFrequency {
return 88.3;
}
and this is my instance method
-(void) chackFrequency {
switch (band) {
case 'F':
if (self.frequency > Value obtained from class method )
frequency=107.9;
break;
default:
break;
}
}
band and frequency are instance variables.
+(void)classMethod
{
[self anotherClassMethod]; // in a class method, self refers to the class
}
-(void)instanceMethod
{
[self anotherInstanceMethod]; //in an instance method self refers to the object, or instance
[[self class] classMethod]; //to call a class method from an instance send the instance the class message
}
so in your case: [[self class] minFMFrequency];
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