if i have a class named
@interface myClass : NSObject {
int firstnum;
int secondnum;
}
//an a method that looks like this
-(myClass *) myMethod (myClass *) f;
@end
what does that method return as? im used to seeing something like (int) myMethod knowing that it returns an integer. but when its returning an object such as the classes name here what can it possibly return? if you'd like ill write out the whole project im working/studying on. (some methods have been truncated to keep the question simple. but if you'd like ill post it let me know. thnx
#import <Foundation/Foundation.h>
@interface Fraction : NSObject {
int numerator;
int denominator;
}
@property int numerator, denominator;
-(Fraction *) add: (Fraction *) f;
@end
#import "Fraction.h"
@implementation Fraction
@synthesize numerator, denominator;
-(Fraction *) add: (Fraction *) f
{
Fraction *result = [[Fraction alloc] init];
// To add two fractions:
// a/b + c/d = ((a*d) + (b*c)) / (b * d)
result.numerator = numerator * f.denominator + denominator * f.numerator;
result.denominator = denominator * f.denominator;
[result reduce];
return result;
}
@end