Monday, 24 March 2008

It's starting to come together


My understanding of Cocoa is getting pretty good now and I'm churning correct code out at a pretty quick rate now. Long gone are the days where I needed to check manuals or download code samples to figure out how to do things. I've changed the main selection menu to a outline view, allow the user to see context dependent information for accounts, investments and currencies. Next to a account name is the $ balance of the account. Next to an investment is the current value of that investment and next to a currency is the exchange rate of that currency to the base currency. Stock and currency prices are automatically downloaded from the Internet in a separate execution thread when the application starts. The yahoo.finance download site seems a little tempermental at the moment, but at least it doesn't cause my application to hang. Also I've changed the popout drawer to also handle investment transactions, meaning the user can add buy, sell, dividends etc.
I'm trying to get foreign currency exchange rate calculations setup. I still need to properly implement two-way account transfers and tidy everything up. The litmus test will be if I can start using the application to record my own financial data.
Finally the user interface needs to be cleaned up and graphs implemented. A big decision is going to be whether to install and develop this in leopard. Leopard does have some nice features included in X-Code but it would be cool to keep this application compatible with 10.4 - Tiger.

Sunday, 2 March 2008

Category maintenance


The whole of the last week has been spent trying to get to grips with the NSOutlineView provided by Cocoa. This gives you a standard leveled and expandable list, as shown in the window to the right. I've finally managed to implement to maintain Categories and SubCategories. No drag and drop yet but the basic functionality to allow users to view, insert, delete is all there. Even better it directly links in with all the underlying class datastructures, meaning that if you change the name of a category, say from "Cars" to "Vehicles" it will update all transactions from immediately. Surprisingly getting this all working wasn't exactly a trivial exercise. The documentation provided by Apple was a little terse and I resorted to plagiarising the only useful example I could find on the web from Big Nerd Ranch.
On a side note one thing I've started noticing about Cocoa is that is operates a quite different development for coding object events then all other development environments I've encountered. Visual Basic, Powerbuilder etc all allow you to object on an object in the interface builder, a push button for example, and directly let you write your code directly as an object property, in the "click" event for example. This means that the code tends to get scattered around the various objects that make up the window. In cocoa you write all your GUI code in a specific class for the window or application. I like this, in that it keeps the code together and hence makes debugging much easier. However for a complex window or application controller, I'm starting to find that the actual objective-c file starts getting enormous in size. Delegate methods get shared objects so every delegate needs to test what object it is that is sending the message. My AppController.m file is already up to 1,000 lines (including comments), and I've hardly started (gulp).