Information Technology Reference
In-Depth Information
int inputB;
int sumAB;
}
@property int inputA;
@property int inputB;
@property int sumAB;
-(id) initWithSum: (int) inA and: (int) inB;
@end
This defines the MathMachine class with some supporting properties. It also creates a single method called
initWithSum: .
FIGURE 17.4
Creating a new class to add a pair of integers
Add the following code to the implementation file, as shown in Figure 17.5:
@implementation MathMachine
@synthesize inputA;
@synthesize inputB;
@synthesize sumAB;
-(id) initWithSum:(int)inA and:(int)inB
{
if (self = [super init]) {
self.inputA = inA;
self.inputB = inB;
Search WWH ::




Custom Search