Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Did you read the delegate documentation? It seems to offer multiple ways to do this.

Also instead of saying "I tried a few things, and they don't work." tell us exactly what you tried and in what way they didn't work. Otherwise we are likely to suggest you re-try things you have tried. Also post your code for the things you have tried: it is possible you have tried the correct thing but have not done it correctly. The more (and better quality) information you provide the better help you'll get.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.