After many fits- and starts- started getting serious about learning Objective-C. I typed in the example Calculator project from the book "Building Cocoa Applications" by Simson Garfinkel & Michael Mahoney. Rather than just typing in the example, I made several changes to learn Objective C.
1. I added a decimal key and implemented the back end code to make the decimal key work correctly. The main challenge was entering leading zeros, i.e. "0.0000...." because those don't change the value of the accumulator.
2. I created a custom NSView object to be the calculator display. My custom view allows the use of custom fonts, and shows the operator as well as the result. The view has several methods.
a. display value of accumulator
b. display current operation
c. append a character to the display
d. clear the display
3. Created UI behavior to make it more like a real calculator... such as ignoring multiple zero button presses if there is no decimal, disabling decimal and unary minus keys once selected, etc.
This project compiled on XCode 2.5 under 10.4.11 Tiger on a Powermac G5. I posted it on Github so others can play with it if they want to:
github.com/bkmoore/Calculator
I think I'm starting to get the hang of Objective-C. I have been creating many mini-programs on my own to learn key concepts, such as how to pass a data structure betwen objects, how to draw with an NSView object, etc.