Archive for the ‘Computers & Internet’ category

Some cool tips and tricks for the iPhone SDK

December 21st, 2008

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.

2) Changing a refresh button to display a UIActivityIndicatorView on a toolbar
Let’s say we have a toolbar at the bottom of the screen and we’ve added a refresh button e.g.
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];
3) How to display an application badge
Now of the three items I discovered this is probably the easiest and it simply the code you need to display the little red badge icon, like the one you see when you have unread email on the mail icon on the home screen.
[UIApplication sharedApplication].applicationIconBadgeNumber = 10;
To hide the badge simply set the value to 0

The dilemma of iPhone Apps

December 6th, 2008

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!

The simply amazing MacBook Air

December 6th, 2008

Unlike many teccys, I’m neither in the Windows, Mac or Linux camp.  I’m actually in all three.  I love using Linux for web servers, they are simply the best operating system in my opinion for running PHP, MySQL and Apache (otherwise known as LAMP).

I also love Windows Vista.  Controversial some might say, however I have NEVER had a single issue with Vista and it works fantastically for me, it looks great as well!

Now onto the Apple Macs.  My history with macs is both relatively recent and actually quite old at the same time.  I can remember as a kid, my dad bringing one of the early Macs home from work and me playing with the drawing tools.

Now my first mac was an iMac Snow, one of the old CRT screens all in one with a CD drive, running OS X 10.2, then came an iBook G4, followed by a Mac Mini.

Then came the current iMac generation which interestingly also makes my most stable Windows PC to date due to the fantastic BootCamp.

Just before I went on holiday this year i finished my latest iPhone App, called iSki, which shows the snow fall and webcams for all the major ski resorts in the world.  I submitted it to the App Store the day before I left, knowing that it usually takes Apple about a week to two to approve initial submissions of new Apps.

At the end of the second week, the App was rejected due to minor issues and I knew could be fixed in seconds and resubmitted.  

How does this relate to the MacBook Air? Well if I had a Mac with me I could have fixed this issue, resubmitted within minutes rather than waiting a week to get home and then a further week to get it approved (which actually it was).

So the answer for me was either the MacBook or the MacBook Air?  The MacBook is cheaper and more powerful but the MacBook Air is incredibly small and very light.  I almost got a MacBook until I remembered the entire reason for the purchase… portability!  Then I remembered the Apple Refurb Store.

The rest is history, I’m now typing this on my Air and it’s a wonderful bit of kit, if I’d have wanted a desktop replacement I’d have gone for the MacBook Pro, for the portable work system, the Air wins on so many levels for me.

I’m on Twitter

October 30th, 2008

I’m now on Twitter, lots of people seem to constantly talk about it, I still don’t really see the point in it but I’m going to give it a go and see whether I like it or not.

In the mean time you can follow me, although I will not promise that it’ll be exciting or informative, here.

myTube for the iPhone

October 1st, 2008
What is myTube?: Information and navigation of the London Underground network.

Highlights:

  • Tube Status: browse the latest tube status updates, including DLR. Change the look and feel from pre-defined skins.
  • Map: view the London Underground map live on the TfL website and optionally download and save the map to your iPhone for viewing offline
  • Nearest Station: find the nearest Tube or DLR station from your current GPS location, distance and directions over ground
  • Route Planner: whilst overground just select your starting station, your destination and find out how to get there including line changes, then view that route whilst underground
  • Navigation: how to get to or from a Tube station using an address or post code
  • Tourist Attractions: Find attractions near to stations and how to get there overground

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.

iPhone development

September 1st, 2008
Xcode icon

Xcode icon

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.

Finally browser companies take the lead in XSS

July 3rd, 2008

My RSS reader popped up with a new article from the IEBlog today, for those that don’t know the IEBlog is the web log from the Microsoft Internet Explorer team.

The article is over at http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx detailing that Internet Explorer 8 Beta 2 will include a Type-1 XSS Filter.  This is fantastic news as along with phishing and nigerian 419 scams, XSS attacks are an evil crime designed to simply steal user’s personal information or money.

Sure us developers should make sure we never make websites vulnerable to XSS scams but that doesn’t excuse people actually using XSS to steal information.  Heck even PayPal recently had an XSS vulnerability.

Well now finally the web browser manufacturers are going to start protecting users who don’t have enough knowledge or even need to know anything about XSS.

Time to vent some anger at PayPal

July 1st, 2008

Now I’m not going to get into the argument of the rights or wrongs of using PayPal as a transaction processor, for me it’s simple, easy, relatively cheap and if you use eBay you’re pretty much forced to use it anyway.  Also not all of this is PayPal’s fault, but I’ll start there

OK so on 14th May 2008 I recieved an overly large transaction payment into my PayPal account, being a bit suspicious I logged in with the intention of refunding the payment, to be notified by PayPal that they had held the transaction pending an anti-fraud review. OK fair enough but that process blocks me from refunding it anyway so I have to wait for PayPal to conclude their ‘investigation’.

Next I get an email on the 15th May from PayPal saying they have reversed the transaction.  Great case closed, resolution I wanted anyway.

Now it starts to get complicated.  On the 22nd May I get a chargeback from PayPal (and they cancel the reversal) saying unauthorised transaction.  So now not only do I have to refund the month I fully intended to refund (and believed that PayPal had refunded anyway) but now I have to pay a chargeback fine for a transaction PayPal would not let me refund in the first place because they placed a hold on the funds.

On the 7th June PayPal closed the chargeback, refunded the month and charged me a chargeback fee.  OK so this should be case close right?  Think again.

Yesterday, 30th June, I get another email from PayPal stating a chargeback again!  What?  You’ve refunded the money, charged me a fine and now you issue me another chargeback?  Apparently the chargeback was initiated on the 28th but they only told me on the 30th.  Apparently the reason for the chargeback is ‘Special – Chargeback created by processing error’  What the heck does that mean? 

In the email it tells me that I should get in contact with my account rep at an email address, so I did, I get an email back telling me  I can’t email them I have to do it from within the resolution centre…. then why tell me to email you then!?!!?!

I’ve added info to it under the resolution centre but I can tell you this if they refund the money again and charge me another chargeback fine I will not let it rest as I’d consider that theft of my money by PayPal!

Now I did say that PayPal isn’t the only group at fault here.  Some responsibility must lie with the person who’s PayPal account was used to make the fraudulent transaction.  How difficult is it… don’t fall for phising scams!

How great is iDVD?

April 2nd, 2008

For those of us just jumping into some DVD editing, how great is iDVD?

But I have to ask one thing, why does it take so damn long to encode the video. It claims about 3 hours for a DV or AVI file, yet VisualHub can convert the same file to a VOB in 12-15 minutes, just no menus.