Tuesday, July 24, 2007

Eet's Aliiiive!

(click for larger image)

It's not even remotely done, but it is ticking. The "Fuel" tab is the only thing with any contents, and its contents aren't finished, so I still have a fair amount of work to do. Not to mention adding the capability to save data, undo, print, etc. But I can successfully enter in fuel data and it will insert the tank in the appropriate spot (based on odometer) in the array, and will then calculate the trip, mileage, cost per gallon, and days between fueling.

Not bad for 2 evenings-worth of work, if I do say so myself (and I do).

My goal for tomorrow is to get the NSPopUpButton (fuel grade selection menu) figured out and actually providing real information. But first I would like to make the "Delete Tank" and "Edit Tank" buttons actually do something. I think I have the logic in my head for how they need to work, but I haven't figured out how to make them enable based on a selection in the table. If I get all of that taken care of, I'd like to figure out how to blank out cell entries that are nil and displaying zero - some kind of visual feedback that those fields are deliberately blank, not the result of a programming error.

I think my biggest challenge for tonight was getting the NSDatePicker figured out. It apparently uses NSDate, and I think I've only played with NSCalendarDate so far. Whatever I tried last night wasn't working. Tonight I managed to get it to accept today's date via [NSCalendarDate calendarDate];, and then finally found a time difference method for NSDate (why the methods I knew of for NSCalendarDate wouldn't work, I don't quite understand) - timeIntervalSinceDate:. And then I figured out that it returns an answer in seconds, so I had to convert for days.

The other change I made today was restructuring the array calculator. I originally had separate methods for each calculation - calcTrip:, calcMPG:, calcDays:, etc. I then realized that each one was doing a complete loop through the array, so a single New/Edit/Delete command could cause numerous loops. That didn't seem efficient. So I restructured those into a single calcTable: method that calculates everything with only a single pass through the array.

I think I should reconfigure my controller files tomorrow. Following the teachings of Mr. Nerd Ranch, I have an AppController, but I realized that it isn't currently doing very much. It really just opens up the tank entry form. Oh yeah, and I want to make that a sheet, also per his suggestion (I'd have probably gone that direction eventually anyway, but he did suggest it before I made the connection). But my TankController is tapping basically all of the other fields, so I might as well let it handle the form, too. Looking ahead, I'm probably going to wind up with a PaymentController, InsuranceController, and so on. I may not even need AppController by the time I'm done.

Le sigh. My real job is getting in the way of my programming. Can't wait until I can make a living doing this.

No comments: