Ok, here goes. I've completed a Cocoa foundation-tool that calculates mean absolute deviation of random integers (Just as a learning project).
I've moved the calculation into a function called "findMeanAbsoluteDeviation()" It accepts a NSMutableArray of NSNumber objects to preform calculations. Anyways. So this works all fine and dandy when I declare it in the same ".m" file as my other code.
#import <Foundation/Foundation.h>
float findMeanAbsoluteDeviation(NSMutableArray * array);
int main (int argc, const char * argv[]) {
...generate random integers, execute function...
meanAbsoluteDeviation = findMeanAbsoluteDeviation(numArray);
}
float findMeanAbsoluteDeviation(NSMutableArray * array) {
...mean absolute deviation maths...
}
and it works fine. Now, I would like to move the function to an external file. I created a subclass of NSObject named "mad". I moved the function into my mad "mad.m", I read up and then re-formatted the declaration to look like
-(float)findMeanAbsoluteDeviation:(NSMutableArray *)array {
...code...
}
and in my "mad.h" file.
@interface mad : NSObject {
}
- (float)findMeanAbsoluteDeviation:(NSMutableArray *)array;
@end
seems all awesome. Right? all I have to do is add...
#import "mad.m"
to the top of my "main.m" file and use the function as I would normally. Well, it doesn't seem to compile correctly.
ld: duplicate symbol .objc_class_name_mad in ------standardDeviation.build/Debug/standardDeviation.build/Objects-normal/i386/mad.o and ------standardDeviation.build/Debug/standardDeviation.build/Objects-normal/i386/standardDeviation.o
"------" is omitted for length's sake
Command /Developer/usr/bin/gcc-4.0 failed with error code 1
Any ideas? Thanks for your help!