Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 201389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:11:41+00:00 2026-05-11T17:11:41+00:00

Ok, here goes. I’ve completed a Cocoa foundation-tool that calculates mean absolute deviation of

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:11:42+00:00Added an answer on May 11, 2026 at 5:11 pm

    You want #import "mad.h", not #import "mad.m" otherwise the class implementation is evaluated twice, hence the error you’re seeing.

    A few stylistic points:

    • If you’re not using an object’s instance variables for anything, you typically write a class method (+) not an instance method (-).
    • There’s no problem declaring a C function prototype in an Objective-C header file, if a class interface doesn’t make sense for what you’re doing. See NSGeometry.h for some examples.
    • If you don’t mutate an array in a function or method, don’t use a mutable array parameter.
    • Consider using standard Cocoa naming conventions for classes, methods and functions.

    For example:

    @interface MEMeanAbsoluteDeviation : NSObject {
    }
    + (float)meanAbsoluteDeviation:(NSArray *)array;
    

    or simply:

    float MEMeanAbsoluteDeviation(NSArray *array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Because GridViewRowCollection implements the non-generic IEnumerable and ICollection interfaces, which… May 12, 2026 at 1:16 am
  • Editorial Team
    Editorial Team added an answer As you notice in the comment, it just says "A… May 12, 2026 at 1:16 am
  • Editorial Team
    Editorial Team added an answer Hmm, I thought there was no short-circuiting in sql server?… May 12, 2026 at 1:16 am

Related Questions

Ok, here goes. I've completed a Cocoa foundation-tool that calculates mean absolute deviation of
Ok, this may be a dumb question but here goes. I noticed something the
Ok here goes: I have a SELECT drop down option with US state names
OK here goes: Need to filter out duplicates and the ability to remove added
I'll try to explain my problem the best I can, here goes: I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.