Well I’ve just got my .tel domain http://richardhyland.tel
Time will tell if it’s any good or going to work, however I’ve actually got a .tel iPhone management tool awaiting approval from Apple.
Well I’ve just got my .tel domain http://richardhyland.tel
Time will tell if it’s any good or going to work, however I’ve actually got a .tel iPhone management tool awaiting approval from Apple.
During the course of developing my latest iPhone application (currently awaiting approval from Apple) I solved a number of issues I’ve had in previous attempts but I’ve finally solved them. Apologies to anyone reading this that thinks, derrr I’ve known this for ages, but hopefully it’ll help some developers with their iPhone applications.
1) Updating the main UI from a thread.
If you call a function using a thread
[NSThread detachNewThreadSelector:@selector(getXML) toTarget:self withObject:nil];
then you might want to update the main user interface e.g. to display a status on a toolbar. Well as it turns out the thread is protected and can’t access the main ui whilst the thread is running. The way to solve this is using the following code
[self performSelectorOnMainThread: @selector(updateBadge) withObject:nil waitUntilDone:NO];
where updateBadge is a function.
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; refreshItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(actionRefresh:)]; refreshItem.style = UIBarButtonItemStylePlain; NSArray *items = [NSArray arrayWithObjects: flexItem, refreshItem, nil]; [toolbar setItems:items animated:NO];
Then by default with that code it would display a refresh button at the right hand side of the toolbar, and when clicking on it would call refreshAction:(id)sender. To be helpful to the end user we might want to change the refresh button to an activity indicator whilst the refresh action was taking place.
The first job is to make the refresh button and flex item a global property so you can call them from different place. Now we also need to create a UIActivityIndicator.
When the refresh action starts you can call the following code to display the activity indicator
CGRect frame = CGRectMake(0.0, 0.0, 25.0, 25.0); UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithFrame:frame]; [loading sizeToFit]; loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); [loading startAnimating]; UIBarButtonItem *statusInd = [[UIBarButtonItem alloc] initWithCustomView:loading]; statusInd.style = UIBarButtonItemStylePlain; NSArray *items = [NSArray arrayWithObjects: flexItem, statusInd, nil]; [toolbar setItems:items animated:NO];
Then when the refresh action stops, simply call the following, as we’ve already made flexItem and refreshItem a global property we don’t need to redefine them or re-point them to their action selector.
NSArray *items = [NSArray arrayWithObjects: flexItem, refreshItem, nil]; [toolbar setItems:items animated:NO];
[UIApplication sharedApplication].applicationIconBadgeNumber = 10;
I’m sure other iPhone developers have come up against the same dilemma as me, you come up with what you think is a great idea for a new iPhone Application to perform a quick search on the iTunes App Store and discover that 5 other people have done the same thing. So the dilemma, do you still write the app because you think you can do better, or do you think of another idea?
Well so far I’ve developed one that I came up with the idea and the same day it got published two others of the same subject did. For the second idea no one had written an app on this subject yet. Yet when I came to submit the final code there were three, yet I still submitted because I’d spend enough time working on it.
Now the second dilemma, I’ve got another idea, which obviously I won’t share until I’ve completed it, but do I actually bother as at the time of writing, no one has done this yet, but will they have done by the time I finish coding the application. Although it will probably only take a fortnight to code.
Heck I’ll probably write it anyway… watch this space!
What is myTube?: Information and navigation of the London Underground network.
This application is designed for usage in connection with the UK London Underground network.
Because of TfL copyright we cannon bundle the Tube map for offline browsing with the application itself. When you use the map it will use the one on TfL’s site, however you can optionally download and save the map for viewing without an Internet connection.
This Application is available from the iTunes App Store.
I’ve developed in a number of languages and systems over the years from Windows Batch Files, Perl, PHP, C#, VB, ASP, etc, etc and I absolutely love Visual Studio 2008 and it’s intellisense.
Now I thought I’d dab my hand at iPhone development. For those that don’t know you have to use a Mac OSX application called Xcode to be able to develop for the iPhone and iPod touch, and then using this in a language called Objective C which seems to be Apple’s own extension to C and C++. To be honest I’ve never gone down the C++ programming route and it probably wouldn’t have been so difficult had the Apple Developer Documentation been any good but basically before Apple lifted their NDA and allowed discussion about developing for the iPhone it was basically trial and error which insanely cryptic compiler debug errors.
Anyway I’ve solved many of the issues now and coming next I’ll talk about my first App that’s already on the iTunes App Store.