Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
April 22, 2018, 09:21:30 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, #7  (Read 2549 times)
cfree
Newbie
*
Posts: 4


« on: May 26, 2009, 08:48:51 PM »

I have compared my code to several other people's code and can't figure out why I am getting error messages and warnings. Any ideas? Here is my code. --Thanks!

#import <Foundation/Foundation.h>

//---@interface section---
@interface XYPoint: NSObject
{
   int xValue;
   int yValue;
}
-(void) print;
-(void) setxValue: (int) x;
-(void) setyValue: (int) y;
-(int) xValue;
-(int) yValue;

@end


//---@implementation section---
   
@implementation XYPoint   
-(void) print;

-(void) setxValue: (int) x
{
   xValue = x;
}

-(void) setyValue: (int) y
{
   yValue = y;
}   

-(int) xValue
{
   return xValue;
}

-(int) yValue
   
{
   return yValue;
}
@end
   
//---program section---
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   XYPoint *myPoint = [[XYPoint alloc] init];
   
   [myPoint setxValue: 1];
   [myPoint setyValue: 2];
   
   NSLog(@"The value of myXYPoint is %i,%i",
         [myPoint xValue], [myPoint yValue]);
         [myPoint release];
    [pool drain];
    return 0;
}

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



« Reply #1 on: May 27, 2009, 07:34:27 AM »

In your implementation section, you forgot to implement the print method:

Code: (Objective-C)
-(void) print;

Cheers,

Steve Kochan
Logged
cfree
Newbie
*
Posts: 4


« Reply #2 on: May 27, 2009, 07:45:25 PM »

Thanks for taking a look. I fixed some other problems and now it works. Smiley
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.