0

My instance variable secondNumber is not declaring itself. Why not? (I am new to programming, so please bear with me.) In Xcode the error says, "Parse Issue: Expected ';' at the end of declaration list.

//  main.m
//  Subtraction
//
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NumberSub: NSObject

{
int firstNumber
int secondNumber
int result 
}
-(void) print;
-(void) setFirstNumber: (int) f;
-(void) setSecondNumber: (int) s;
-(void) resetAll;
-(void) printResult;
@end

@implementation NumberSub

-(void) setFirstNumber: (int) f;
{
firstNumber = f;
}

-(void) setSecondNumber: (int) s
{ 
secondNumber = s;
}

-(void) print
{
NSLog(@"%i - %i = ", firstNumber, secondNumber);

}

-(void) printResult
{
NSLog(@"%i", firstNumber - secondNumber);
}

-(void) resetAll
{
firstNumber = 0;
secondNumber = 0;
}

@end

int main (int argc, char *argv[])
{
NumberSub *subtractNumber = [[NumberSub = alloc]init];



[subtractNumber setFirstNumber: 10];
[subtractNumber setSecondNumber: 5];

[subtractNumber print];
[subtractNumber printResult];

[subtractNumber release];   
return 0;
}
1
  • 1
    "Parse Issue: Expected ';' at the end of declaration list." is a pretty clear statement ;) Commented May 6, 2012 at 10:22

1 Answer 1

1

You forgot the ; at the end of each lines

@interface NumberSub: NSObject

{
    int firstNumber;
    int secondNumber;
    int result ;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Don't forget to accept the answer by click on the small check sign :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.