Hello, still newbie here but I've watched/tried some IOS programming by following iTunes U courses.

My understanding is "set" and "get" are the norm/convention to use when setting/getting variables in objects.

The following code works:

#import <Foundation/Foundation.h>

// Start of @interface section

@interface Fraction: NSObject

{

int numerator;

int denominator;

}

- (void) print;

- (void) setNumerator: (int) n;

- (void) setDenominator: (int) d;

- (int) getNumerator;

- (int) getDenominator;

@end // @interface

// Start of @implementation section

@implementation Fraction

- (void) print {

NSLog(@"%i/%i",numerator,denominator);

}

- (void) setNumerator:(int)n {

numerator = n;

}

- (void) setDenominator:(int)d{

denominator = d;

}

- (int) getNumerator {

NSLog(@"%i",numerator);

return numerator;

}

- (int) getDenominator {

NSLog(@"%i",denominator);

return denominator;

}

@end // @implementation

// Start of main program section

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

{

@autoreleasepool {

Fraction *myFraction; // create object variable myFraction

int num, den;

// Create an instance of the object Fraction

myFraction = [Fraction alloc];

// myFraction = [Fraction init]; -- no need to init if we're using Xcode 4.3.2

// assign value to fraction

[myFraction setNumerator: 1];

[myFraction setDenominator:3];

// Display fraction object

[myFraction print];

num = [myFraction getNumerator];

den = [myFraction getDenominator];

NSLog(@"The numerator is %i, and denominator is %i",num,den);

// free up object

[myFraction release];

// [pool drain]; -- no need to pool drain if we're using Xcode 4.3.2

}

return 0;

}