Wednesday, 18 March 2009

kiwired.co.nz is up

In order to get your iPhone App on the App Store you need to provide Apple with a support website. This was a bit of a problem for me as although I've reserved www.elounge.co.nz I haven't got around to paying for the hosting of it yet. For the time being I've borrowed space on a friend's website and elounge can be found at www.kiwired.co.nz/elounge. The webpages themselves were developed quickly one morning using iWeb, which comes packaged with iLife on all Macs. I was very impressed with iWeb. I've tried building websites before and as a beginner I've found iWeb to be by far the easiest to learn and use. More content will be provided soon but for now it's onto iPhone SDK 3.0 and the next big thing.

Sunday, 15 March 2009

Submission complete

nInvaders has been submitted to Apple as of 11 March. I've read a few horror stories about the backlog of iPhone App approvals which Apple is having to deal with so I'm not exactly waiting with bated breath for any feedback, but will put a post up as soon as any arrives. The whole process to submit the App was a little laborious. If I were to do it again it make sure I had the 512x512x72 blowup of the icon ready to go, the write up complete and the screen shots taken. Apple has a presentation video on the iPhone Connection website which is very handy in preparing you for all the assets you need to have in place before you can successfully submit your App.
Now that that's done it's back to moneyLounge development. I was never very happy with the presentation of the Tree View so I'm doing a little rework of that interface to clean it up. Next Saturday I also have a photoshop course to attend so I'm hoping that'll speed up my graphics development and make everything a whole lot prettier. It's all very well to have a elegant set of classes and data structures but no one really sees that - a nice icon and some fancy pictures makes all the difference.

Thursday, 5 March 2009

nVaders

My first iPhone App is now complete and ready to be submitted to Apple for the iStore review. Some awesome graphics work from Sam Douglas over the past week has given a real sparkle to the game, including the neat little icon shown here. Now I just need to get a bigger version of icon made of the iTunes Store and a webpage thrown together and it'll be all good to go. It should be neat seeing people actually downloading it and since it'll be free we're assured of some market.

Thursday, 5 February 2009

Universal Binary

I just copied moneyLounge across to my old Mac G5 and, too my horror, discovered that it wouldn't even startup. I was getting the message "invalid architecture". Some hunting around on google quickly determined that I needed to compile a universal binary version of moneyLounge. This is done simple by changing the "Architectures" setting in the Build properties of the target. I'll guess this means I'll need two targets from now. All went well except for one interesting (and hard to track down) run error. This concerns the use of code such as:

int row;
if(row==NSNotFound) then ....

In the native architecture of my Intel Mac this code would work fine, but in the 32/64 bit Universal version it didn't. This was because NSNotFound is defined as the largest possible long datatype rather then integer. I guess this is the difference between the 32 and 64 bit versions. The upshot of this was that I recoded all my "int" datatypes to NSUInteger, making the code a lot more generic in any case. Something to bear in mind I guess - try and use the NS datatypes rather then the simple C versions.

Tuesday, 3 February 2009

Number Invaders


moneyLounge has reached a stable build now and I'm actually able to use it for my day to day finances. That means I finally have a replacement for MS Money on the Mac that I can actually use. There's still a few bits and pieces that could be improved upon and I intend over the next few days to test the release on my G5 and also give it to a few users to beta test. But for the past couple of weeks I've been happily working on my first iPhone Project - Number Invaders. It's a simple game based on the old 1980 Casio Calculator game where you 'shoot' numbers advancing across the LED display towards you, and it has turned out to be an ideal introduction project to iPhone development, as it involves simple graphics, timing events and GUI development. The actual coding is very similar to standard Mac Cocoa and Objective-C and so far the hardest part has been getting the setup and configuration working. If you're intended to join the iPhone developer program and setup your Mac then I would encourage you to visit Ralf Rottmann's guide as he takes you past all the potholes that Apple has often neglected to document. I now need to get Calculator Invaders ready for the App Store and I'll try to be a little more regular at updating my blog of with what happens thru the Apple QA process.


Saturday, 13 December 2008

Download share price history from Yahoo Finance

This problem took me a little while to figure out so I'm pretty happy that I've finally managed to get it working, and with a pretty simple solution. The crux of the problem was how to fetch from the internet a share price history for any given stock over a period of days, months or even years. As it turns out yahoo.finance offers a HTTP page which nicely returns this information for you. The format of the page address looks something like this:

http://ichart.yahoo.com/table.csv?s=MSFT&a=01&b=00&c=2007&d=31&e=11&f=2008&g=d&ignore=.csv

where:

s=the stock code and stock index if outside the US (i.e. MSFT or TEL.NZ)

a=the day of the month for the start date

b=the month of the year for the start date. Note that months seem to start from 0 so Jan is 0 and 11 is Dec

c=the year of the start date

d=the day of the end date

e=the month of the end date (also convert to go from 00 to 11)

f=the year of the end date

This web query can be used in a browser to return a list of share price data for the named stock from the start date to the end date. The list will show the opening value, closing value, and other data for each day in comma separated format. You simply need to parse this result set in a loop and use it as required.

In the sample code below I've made use of the NSURL and NSData objects to grab the data. Note, this code is reference only. It won't actually work, it's just to give you an idea of how this is done:


httpString = [NSString stringWithFormat:@"http://ichart.yahoo.com/table.csv?s=%@&a=%@&b=%@&c=%@&d=%@&e=%@&f=%@&g=d&ignore=.csv", stockCode, firstMonth, firstDay, firstYear, lastMonth, lastDay, lastYear];

NSURL *url = [NSURL URLWithString:httpString];

NSData *data = [NSData dataWithContentsOfURL:url];

NSString *s = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

NSArray *lines = [s componentsSeparatedByString:@"\n"];

NSArray *line;

for(i=0;i<[lines count];i++) {

 sCurLine = [lines objectAtIndex:i];

 line = [sCurLine componentsSeparatedByString:@","];


 /* the download should always contain 7 fields, but yahoo might change this at any time */

 if([line count]==7) {

  thisDate = [NSCalendarDate dateWithString:[line objectAtIndex:0] calendarFormat:@"%Y-%m-%d"];

  thisPrice = [[line objectAtIndex:4] floatValue];


  /* thisDate and thisPrice should now contain the date and price for this entry in the download (most recent first) */

  }

}

Tuesday, 2 December 2008

swishLounge

Having left my contract at Telecom I've had a little extra time to work on moneyLounge and I'm pretty happy with the results, it's starting to look and feel like a real application. The attached screenshot shows a few new features. I've added a ticker in the bottom left of the screen. This fades in and out details for various accounts/investments or categories that the user might be interested in. For example it can show price changes in an investment, how your net worth has changed in the month or how an account balance changed. The background of the ticker was created using a Quartz Composer Gradient interpolation and the effect is to give a subtle change of light intensity, as if a light is passing over the ticker. Most of the recent changes however have been made to the background code, mainly design tidy ups. I still need to implement a drag-drop facility to enable the user to grab an account or investment and drop it into the ticker to update it. Rather then using a Application Controller to manage all on screen objects I've divided the work up into a bunch of controllers for the different types of data objects, all of which are inherited from a generic moneyLounge controller. Some of the early objects I created have also had their interface tidied up and making changes or adding enhancements has become much easier with the cleaned up design. I've also begun methodical debugging of the code and am uncovering bugs underneath every stone that is unturned. Fortunately there's been no show-stoppers yet but next time I do something like this there will be a detailed design written before I start any coding.
Features requiring implementation include:
1. Complete the ticker
2. Various Universal graphs like Net Worth, Passive Income, Investment Performance.
3. File Export to QIF.
4. OCX load
5. Import share price history from CSV
6. Reinvestment dividends
7. Loan accounts
8. Color associations with Accounts and Investments.
9. (other stuff I haven't thought of just yet)
10. A design with the nine points I've mentioned above fleshed out properly