Tuesday, 27 October 2009

Changing the Annotation on the Current Location

The MKMapKit class comes with a property you can set to show the current location of the iPhone:

mapView.showCurrentLocation = YES;

This will show the little blue bubble on the map view and have the radar effect like Google Maps. However when the user touches the bubble it'll just show the text "Current Location". To set it to something other then this you can use:

mapView.userLocation.title = @"a different annotation title";

To set it to the address of that location you need to use the MKReverseGeocoder class, which is also found in the MapKit framework. You'll need to provide this delegate method in your viewController class:


- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation


This gets called whenever the location changes. Within this method you can then call the Reverse Geocoder service using:

/* warning! use this sparingly */

MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc initWithCoordinate:newLocation.coordinate];

geocoder.delegate = self;

[geocoder start];


Next declare two more methods.

-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error

{

[geocoder release];

}


-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark

{

[geocoder release];

mapView.userLocation.title = placemark.title;

}


The last line of code will update the title of the bubble with the correct location.

Now for the important bit. The reverseGeocoder is making a call to a Google Web service and using the latitude and longitude you provide it will return a street address or place name. If you call this function everytime the user location changes then you'll be generating a huge amount of unnecessary network traffic from and to the iPhone and putting strain on the google servers to handle your constant address requests. To minimise this I would suggest you use one of two approaches. Either keep a instance variable to keep track of the distance travelled since the last time you requested a reverseGeocoder location and only start the reverseGeocoder when a certain limit has been reached (i.e. 50 meters). You can use the CLLocation method getDistanceFrom to find this distance. Or, you could declare a NSTimer then calls starts the reverseGeocoder only after a certain interval has passed, 10 seconds for example.

Best of luck implementing this.

Timetable NZ

Next off the assembly line from the eLounge App development factory comes Timetable NZ!

I'm not going to wrote another blurb about this App as when you're publishing an App on the App Store you tend to get a little tired of writing promotional material, but if you're interested please take a look at www.elounge.net.nz. This App has been a few months of part time work in the making with some great support from the kind people of the Greater Wellington City Council and Metlink.

One thing I noticed whilst developing it was how google and the internet has completely changed software development. Whenever I came across a curly problem with the iPhone SDK, X-Code or Cocoa Touch my first port of call wasn't to try and think of a solution - it was to google the problem and try and find a code sample to get me started. Naturally I couldn't make a one to one copy and paste but I hasn't once failed to help me overcome a problem far faster then I ever would have had I been required to figure it out myself.

It's highlighted the importance to me of having developers like myself post solutions wherever possible on the internet. This is something I haven't been particularly diligent about but I'll try and make more posts in the future.

Sunday, 13 September 2009

unable to read unknown load command 0x80000022

A quick post about the error message above which I started getting this week in a couple of iPhone and OSX XCode projects. In the console debugger it would spam this message whenever I ran an application, although it didn't seem to make any difference. However it obviously made it harder to debug code.

The reason appears to be that I've upgraded to Snow Leopard without upgrading the developers tools at the same time. Hence I was using the 10.5 version to XCode to compile in a 10.6 environment. I've fully upgraded now and the warnings have gone away.

I couldn't find much documentation on this on the internet so thought I'd make a quick post about it. Please feel free to comment if you've been getting this also.

(I also noticed that using Command-Left Arrow, Command-Right Arrow in the Xcode editor would cause XCode to crash). The upgrade fixed this also.


Thursday, 30 July 2009

Telstraclear cable access woes

At home I use a Telstraclear cable connection to hook into the internet. My telstra cable modem connects to a 4 port wireless cable router and from there it has ethernet connections to my 2 Macs and a wireless connection to my iPod Touch. In early July I started having connection problems whereby my internet connection would intermitantly drop off for up to 30 seconds. This particurly noticable if you use your internet for web browsing or downloading things but when online gaming or using VOIP applications latency becomes a big issue. So I called Telstra and tried over several nights the usual series of tests of unplugging my router and connecting directly to the modem, monitoring the modem status, changing enternet cables around and using different PC's to connect - all to no avail. Someone from Telstra came over and replaced a few pieces of equipment - also to no avail. Eventually they put me onto Downer Engineering and so began a one week assignment of keeping in touch with those guys to help them test whether fixes they were making at their exchange made any difference. I ended up have to write a little ping script "ping www.nzherald.co.nz > pingtst.txt" and leave that running every night to record the number of ping drops over the course of an evening. Eventually they were able to fix the problem but not before I found that lots of other Telstra customers in the Wellington region were also suffering similar issues.
What bothers me is that not once did Telstra report or acknowledge that there was an issue. I'm sure that there were lots of other people around the area also went through the same hassles as I did. A simple website notice or email explaining the issue with the exchange and or an email to affected customers would have at least informed people like me that the issue isn't at their end. Note that my gripe isn't with Downer Engineering - they were very good in staying in touch and prehaps Telstra might want to take a feather out of their hat.

Thursday, 26 March 2009

Back to moneyLounge

Now that Number Invaders is finally out I have resumed work on moneyLounge with the aim of finishing off all existing functionality, closing the final few bugs and getting it out to some users for alpha testing.  I knocked together a icon/logo for the software last night which can be seen in all it's hi resolution glory here. One of the challenges with Mac Programming is that as a developer you have a very high self expectation to build software that looks really great. Actually achieving this can be quite a challenge as, after all, we are coders and not graphics designers or artists. I managed to get myself on a Photoshop Introductory course over the weekend and it's helped immensely, in that now I'm able to do most of my in-application icon, button and graphics myself and do a reasonably good job. It's a real boost to the confidence when you're working on developing an application that doesn't just work well but also looks good. I'll try and post a few more screen shots once I've finished the various final odds and ends to get this all working. Once done it'll be onto the next iPhone App, something I'm really looking forward to.

Friday, 20 March 2009

Number Invaders is live on the App Store


Whatever rumors you may have heard about App Store approvals recently taking a long time I can confirm that in my case it took almost exactly one week to go from submission to approval. Once you get past the hurdle of preparing all your assets and assuming that you have a bug free and leak free App it seems that Apple is quite quick in approving free Apps. When they've approved it you get sent an email from iTunes Connect saying that your App is "Ready for Sale" and is apparently on the App Store. However, it does seem to take a while for the App Store Search Indexing to figure out your App exists as over the first 24 hours I actually had quite a hard time finding Number Invaders and could only search for it using the company name "eLounge". Now it is coming up properly with a search on "Number Invaders". It's also quick amazing to see how quickly the game gets spread over the internet and it's fun reading comments of others about the game. I've had a couple of feedbacks so far related to the high quality of the graphics but the rather poor quality of the sound. If I could just get my hands on the real thing to record the sound I'll send thru an update with decent sound effects. 

Still, it's a real buzz to have finally published a piece of software that is actually used by real people rather then just big corporations and it's a real spur for the next iPhone project (whatever that may be).

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.