Information Technology Reference
In-Depth Information
self.sumAB = inA + inB;
}
return self;
}
}
@end
FIGURE 17.5
Implementing the initialization and addition method
NOTE
If you're new to Objective-C and Cocoa, this may seem like a lot of code for a simple operation. In fact, most of
this code creates a new class and defines one possible custom initialization method. Although this is a long-win-
ded idiom, it's standard for Objective-C and Cocoa classes. In a real math framework, the class would be extended
with many more properties and many other initialization and processing methods.
Creating a test case
Now that the project includes something to test, you can add the code to test it. Tests are defined as individual
methods in the <ProjectName>Tests class. The name of each method must start with test . Methods
that begin with any other string are ignored.
Search WWH ::




Custom Search