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 999799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:24:38+00:00 2026-05-16T07:24:38+00:00

operator class: #import <Foundation/Foundation.h> @interface operator : NSObject { int number; } @property int

  • 0

operator class:

#import <Foundation/Foundation.h>


@interface operator : NSObject {

int number;
}

@property int number;

@end

@implementation operator

- (id)init{
    self = [super init];
    if (self) {
    [self setNumber:0];
    }
    return self;
}

@synthesize number;
@end

main.m:

#import <UIKit/UIKit.h>
#import "operator.m"

int main(int argc, char *argv[]) {

id operator1 = [[operator alloc] init];
id operator2 = [[operator alloc] init];

[operator1 setNumber:10];
[operator2 setNumber:20];

int answer = [operator1 number] + [operator2 number];

printf("The answer is %d",answer);



NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

I get an error -> ld: duplicate symbol _OBJC_IVAR_$_operator.number in /Volumes/Home/Desktop/testing/build/testing.build/Debug-iphonesimulator/testing.build/Objects-normal/i386/operator.o and /Volumes/Home/Desktop/testing/build/testing.build/Debug-iphonesimulator/testing.build/Objects-normal/i386/main.o

This is my very first time I program in ObjC. Am I doing something wrong?

I tried the “Clean all targets” fix that I found on google but did not 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-16T07:24:38+00:00Added an answer on May 16, 2026 at 7:24 am
    1. You should never #import an .m file into another file. You import the .h file, if it’s needed.
    2. You should not have code executing in main before you create the autorelease pool. That is going to cause problems sooner or later. In this case, you test code should probably go in application:didFininshLaunching instead.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

self.response.out.write(\n) When i upload a data of multiline using text property and then printing
What is the difference between new operator and Class.forName(...).newInstance() ? Both of them create
Is there a way to use block class scope resolution in C++ so that
Say want to store the following: typedef std::function<void(int)> MyFunctionDecl; ..in a collection: typedef std::vector<MyFunctionDecl>
Here is a Python postfix notation interpreter which utilizes a stack to evaluate the
I was writing a simple genetic program to test out the process, but got
I am trying to find a way to use C++ classes in D. http://www.digitalmars.com/d/2.0/cpp_interface.html
I am writing a program to solve postfix problems. I am not needing help
I do like the way I can treat lists in Python. It does any
I'm struggling to design the server-side script that responds to requests from an Ajax

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.