« irc channel to discuss the challenges | Main | Source for weekly challenge number 2 »

January 08, 2007

The weekly cocoa app challenge, week 2

Check out that sweet icon too:

week-2-airguitar.zip

Be sure to keep your work handy, I'll probably be expanding on it.

Posted by Chris Forsythe at January 8, 2007 09:21 PM

Comments

Yay, finished. That one was a quickie. Someone with just a little Applescript experience should have fun with what they'll learn from this challenge. Might I also suggest that you lock the window size :)

Posted by: Justin Prine at January 9, 2007 12:58 AM

I didn't push the applescript into their own script files as they were so small. And I didn't ask if iTunes was running before performing the track changes. I guess I would assume if someone is using the Air Guitar app and pressing the track-forward button, they'd want iTunes to launch if it weren't already running.

Love the icon:)

http://myztik.katan.com/?page_id=149

Posted by: Myztik Jenz at January 9, 2007 08:50 AM

i have a question about the first challenge, but wanted to post it here as to not give anything away. after reading the docs i solved the challenge but i implemented it a bit different than the provided solution. i did not declare NSURL var's, instead i just used the class method
+ (id)URLWithString:(NSString *)URLString...
so [[NSWorkspace sharedworkspace] openURL:[NSURL URLWithString:@"fedex.com"]];
so my question would be which method (if any) is better? i was under the (possibly mistaken) impression that my way would add those to the autorelease pool, so i would not have to explicitly deallocate them. any thoughts on this?

Posted by: clint at January 9, 2007 11:50 AM

I finished this too. I was a little frustrated, but that's because I'm just learning Cocoa. Thanks to Google and knowing how to find the NIB file I was able to sort it out. And I got a little taste of debugging too.

Posted by: Will Gauvin at January 9, 2007 10:30 PM

I think the challenge is great. Would you be prepared to come on the Late Night Cocoa podcast and talk about it.

Posted by: Scotty at January 10, 2007 09:26 AM

Perhaps the next challenge could be adding a toolbar to a window? I have so far been unable to figure out how to do this.

Posted by: Joe at January 10, 2007 01:23 PM

I was thinking hotkeys next week, but that can be pushed if you guys want toolbars.

Posted by: Chris Forsythe at January 10, 2007 02:17 PM

tool bars would be great, i was wondering how to do that myself

Posted by: clint at January 10, 2007 04:36 PM

Scotty,

I tried to email you, it didn't go through. I'd be glad to. Whois this domain or growl.info and you'll find my email address.

Posted by: Chris Forsythe at January 10, 2007 06:49 PM

Yay toolbars!

Posted by: me at January 11, 2007 11:45 AM

I agree with the guys above, toolbars would be fun for one of the upcoming challenges.

Posted by: Justin Prine at January 11, 2007 03:51 PM

Thanks again. A suggestion and a question:
It would be great if the files in your zip archive would unzip into some folder starting with week-n.
Is there an RSS-Feed for the weekly Cocoa app challenge?

Posted by: Nico at January 11, 2007 05:22 PM

These challenges are too easy.

Posted by: John Doe at January 14, 2007 01:55 AM

Myztik - I had the exact same question. URLWithString returns an autorelease NSURL. You can use it exactly as you are doing and forget about it. However, notice that you are creating a new NSURL each and every time the button is pressed. The sample application saves the URL in the controller so that you only create one instance for the life of the app. On a small app like this I don't think there's really any difference.

If you did want to keep your URLWithString around, you'd need to retain it, at which point you'd probably find the alloc / initWithString combination preferable.

Posted by: Norman Richards at January 14, 2007 11:50 AM


I got behind. The real job stepped in and whacked me upside the head. But here's my week 2 solution.

http://www.smallbutdisorganized.com/2007/01/18/the-weekly-cocoa-challenge-week-2/

I didn't originally have the scripts as files in the package, I hard-coded them as strings. But I examined the package contents to snag the app icon and noticed that was how you implemented it, so I rewrote mine to do the same. Only my script files are in source form rather than compiled. I can see pros and cons either way.

I also noticed that there was no script in your app for launching iTunes. This was what tipped me off to use NSWorkspace to launch iTunes. Without that I would have had no use for NSWorkspace in this app.

My scripts, however, don't start iTune or otherwise check if its running before trying to go to the next or previous track. My bug. My bad.

Posted by: Sean at January 18, 2007 12:41 AM

@Norman -
I actually posted that question.
i understand now why his method is better overall. thanks for explaining, once you pointed it out it made complete sence. with a small program it's negligble, but the habbit of doing things that way could burn me in the future.
thanks again! and thanks for the challenges Chris!

Posted by: Clint at January 18, 2007 09:53 PM

I have posted my solutions for the first two challenges, as well as an altogether too long writeup at http://angrymen.org/2007/01/23/weekly-cocoa-app-challenges-for-the-first-two-weeks/

I'd like to thank you for doing this. It was just the motivation I needed to explore the Cocoa framework a bit more.

Posted by: Michael Buckley at January 22, 2007 07:31 PM

Post a comment




Remember Me?