Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
July 23, 2018, 12:53:38 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Chapter 3 Exercise 7  (Read 1651 times)
harveylind
Newbie
*
Posts: 1


Email
« on: March 04, 2010, 03:39:32 PM »



I get the following error message after compiling my program even though no specific line of code is flagged.

ld: duplicate symbol _main in /Users/harveylind/Desktop/XYPoint/build/XYPoint.build/Debug/XYPoint.build/Objects-normal/x86_64/XYPoint-25DBA68B8CEAD333.o and /Users/harveylind/Desktop/XYPoint/build/XYPoint.build/Debug/XYPoint.build/Objects-normal/x86_64/XYPoint-25DBA68B8CEAD333.o

What did I mess up?
harveylind   Huh


//
//  XYPoint.h
//  XYPoint
//
//  Created by Harvey Lindenbaum on 3/4/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

//--------- @Interface Section  --------------
//Define XYPoint Class

@interface XYPoint : NSObject
{
   int xCoordinate;
   int yCoordinate;
}



-(int)  xCoordinate;
-(int)  yCoordinate;
-(void) print;
-(void) setXCoordinate: (int) x;
-(void) setYCoordinate: (int) y;


@end

//--------- @implementation Section  --------------
@implementation XYPoint


-(void) print
{
   NSLog (@"X and Y Coordinates: (%i,%i)", xCoordinate, yCoordinate);
}

-(void) setXCoordinate: (int) x
{
   xCoordinate = x;
}

-(void) setYCoordinate: (int) y
{
   yCoordinate = y;
}

-(int)  xCoordinate
{
   return xCoordinate;
}

-(int)  yCoordinate
{
   return yCoordinate;
}

@end






#import "XYPoint.h"

//------- Program Section ---------

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   XYPoint *myPoint = [[XYPoint alloc] init];

   // Set X and Y Coordinates
   
   [myPoint setXCoordinate: 5];
   [myPoint setYCoordinate: 10];
   
   // Display Coordinates
   
    [myPoint print];
   [myPoint release];

    [pool drain];
    return 0;
}







Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: March 05, 2010, 02:22:16 PM »

Did you put both the interface and implementation sections in XYPoint.h?  That's what it looks like.  Remember, the implementation section normally goes into a separate file, in this case XYPoint.m.

Cheers,

Steve Kochan
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.