Sunday, September 28, 2008

SECO!

Since I'm also a Space geek, I did not miss the LIVE broadcast of the 4th flight of SpaceX's Falcon 1 launch vehicle ... It was especially important to see it, since they finally made it to orbit! Yahoooo! Here's a recording (on YouTube) of the live feed for your enjoyment :-)


Thursday, September 25, 2008

The Dark Side (TM) clouds everything ...

I have been observing for a while now how things are panning out with Apple and the App Store. Since I haven't started developing for the iPhone yet (but soon! I'm starting a new full time job doing just that in 6 days!!, I can't add anything of value to the on-going discussions, except joining the group of bystanders and shaking my head in disbelieve at each moves Apple made. Even thought I always had a soft spot for Apple since my days on an Apple IIc, I'm not naive enough to believe they can do no evil ... especially since they sort of have a proven track record of not always playing fair and square. Lots of fore front bloggers have commented about the whole situation (e.g Daring Fireball, Wil Shipley ...), including the still standing NDA, which have already caused the publishing of a programming book to be canceled. Now, as long as you can stay anonymous (does that really mean anything on Internet these days?), it is not impossible to post details (including tutorials) on Cocoa Touch. It is a bit of a risky endeavour I must said, but very much appreciated by newbies iPhone devs like myself ;-)

On another subject, but still related ... The Technologizer.com web site has an interesting post with a bunch of old to recent Apple's TV ads, make sure to check it out for a bit of nostalgia.

Wednesday, September 24, 2008

Toying around ... #2

A few pointless posts ago, I was talking about Nibless Cocoa applications, and how Jeff Johnson, had a ready to use solution for us, Interface Builder cheaters. Jeff's elegant solution is build around using Cocoa NSObject's ability to have a class pose as another class (but it must be a parent class). The trick been to make sure that when the application is starting, the NSBundle created to load the main NIB file does not load it, and instead just pretend to have done so. The method works like a charm (granted that the entry NSMainNibFile in info.plist has been removed), however there is just a little problem: the class method poseAsClass has been deprecated in OS X 10.5 and is not even present in 64-bit Cocoa. I have no idea whatsoever this is been phased-out by Apple. Since a similar facility exists in Objective-C and GNUStep, it's not clear at all why this have to go ... Security concern maybe? Whatever the explanation, I'd like to know ...

So ... since I'm interested in a solution that can work from 10.4 and beyond on PowerPC and Intel, 32-bit as well as 64-bit, I had to go back to the drawing board and come-up with an alternative solution, likely something not as elegant. Hopefully, thanks to Objective-C's dynamic abilities, it is possible to replace on-the-fly a method implementation by another function (as long as it have a compatible signature). Scott Stevenson have made a an excellent post on this, which I used as the base of my solution.

The idea is relatively simple: replace the NSBundle's class method loadNibNamed:owner: by my own implementation function and call the original method only in when necessary. Since I wanted to have this automatically done as part of a special type of application, I derived NSApplication in HZNiblessApplication, implementing its object method init to do the dirty work:


- (id) init {
if ((self = [super init]))
{
Method lMethod = class_getClassMethod([NSBundle class],@selector(loadNibNamed:owner:));
if(!lMethod)
NSLog(@"NSBundle+loadNibNamed:owner: not found!");
else
{
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4
gDefaultNSBundleLoadNibNamed = method_setImplementation(lMethod,(IMP)loadNibNamed);
#else
gDefaultNSBundleLoadNibNamed = lMethod->method_imp;
lMethod->method_imp = (IMP)loadNibNamed;
#endif
}
}
return self;
}
view rawThis Gist brought to you by GitHub.

As your can see, the method basically retrieve the method within the NSBundle class, and swap its implementation with a function called loadNibNamed. Since we need to call the original method to perform its duty when there is a need to load a bundle, we save the pointer to the function in a global variable named gDefaultNSBundleLoadNibNamed. Let's have a look now on how that replacement function is implemented:


BOOL loadNibNamed(id aObject,SEL aSelector,NSString *aNibNamed,id aOwner)
{
if (!aNibNamed && aOwner == NSApp)
return true;
else
return (BOOL)(*gDefaultNSBundleLoadNibNamed)(aObject,aSelector,aNibNamed,aOwner);
}
view rawThis Gist brought to you by GitHub.

From there, all that is needed is to replace the value of the NSPrincipalClass key in the application's info.plist by HZNiblessApplication and get your application delegate to fill in the Application menu from -applicationWillFinishLaunching: ... Okay, yeah I'm simplifying a bit here, but you get the point I'm sure :-P

As you have noticed, I finally figured a way of putting neatly formatted code (hmm ... at least on Firefox) on this blog, courtesy of github.com.

Friday, September 19, 2008

Am I a PC?

Microsoft has released yesterday its new series of ads, replacing the series started a couple of weeks ago with the comic duo Gates & Seinfeld. I think they are not that bad. Sure, it doesn't said much of why using a PC (instead of a Macintosh) is better, but at least it's not as wild as the previous ads. See for yourself:




Rogue Amoeba's developer Mike Ash, has added an interesting post (one of many in fact) on his blog, regarding his iPhone development story. Very interesting and a little bit scary ... Hopefully for him, what he shared won't fall under the infamous NDA, causing him to loose his developer program seat.

Wednesday, September 17, 2008

iCapricious

There has been a lot of talks on the Apple and iPhone developers communities lately about the issue of what application get to be on the App Store or be rejected from it ... The folks behind The Joy of Tech have summed-up in their hilarious (and yet lovely) usual way:

So far, since there has been only an handful of rejected applications, I don't think it is fair to Apple to said that they are abusing their gate keeper role ... however, since not all developers may be has vocal about their rejection as Podcaster's author ... who knows really?

Tuesday, September 16, 2008

The Force is weak with this one ...

The Force Unleashed has been out since yesterday for iPhone/iPod, and without much surprise it's really a huge disappointment, gameplay wise. Don't believe me? Check out this video provided by TouchArcade.com:




Yep ... and it get worst, people that reported having purchased it, said that they were able to complete it 90 minutes ... Sure it's only 10 bucks, but still ... Ah well, what can we do except skip it and spend more time playing with Enigmo ... Now, that's a fun (and yet very geeky) game :-)

Friday, September 12, 2008

Goofing around?

As I was watching the second of the new Microsoft's Ads last night, I came to realise to my uttermost surprise that I was enjoying it. Yeah, you read it right, I just said that I enjoyed it. Sure, I did find it a little long (over 4 minutes), and I still have no idea where this is all going, but I thought it was goofy and not without a certain charm. Still that won't get me running to my local electronic shop and getting a new PC, nor a copy of Vista ... But maybe that's not the goal of the campaign? What if the intent was to make Microsoft appears less of the evil juggernaut we have come to believe it is? Meditate on this, I will.

Wednesday, September 10, 2008

One less thing ...

Since I'm waiting for an update to the MacBook, and that none was announced yesterday, I can't help but feeling disappointed by yesterday Let's rock event. Sure, funky color Nanos and the touch finaly getting a speaker and a physical volume control are good news, but still this was in no way the big deal event which was announce by the PR (how typical ...). Yet, the 2.1 firmware update was released (minus the pre-announced push capability, what happend to that?) and that's a good thing. This time around, Apple was less stingy with details on the update, and so far I have found the UI to be a bit snappier, however 3rd party applications still take, like, ever to load ...

Monday, September 8, 2008

The force (un)leashed

Like most Star Wars fan that happens to own an iPhone or an iPod touch (my case), I was looking forward to September 16th release of The Force Unleashed. However, after watching a video showing the gameplay ... I'm bitterly disappointed. I was hoping for something similar to Jedi Knight 2 where I could play as Darth Vader's secret apprentice (real name Galen Marek) ... instead it looks like the game will be cinematic and mainly finger gestures based. What's the point of carrying a cool looking light saber around if it's only used to return laser blast? ... Okay so yeah, FPS friendly controls on a device such as this is tricky, but not impossible ...

While I am on this subject, I should mention that I been reading Timothy Zahn's first sequel to Episode VI: Heir to the Empire. So far it is okay ... nothing exceptional really, but it's not too bad either. It is the first time that I'm reading a Star Wars expanded universe book. Since I had some downtime between Dune's universe books I thought I gave that a try.

Wednesday, September 3, 2008

The bleh 2

I was saving this post for some report on my Cocoa progress, but instead I feel like I should add my voice to the many that have commented on the new CBC Radio 2, which launched yesterday. I have to admit that I had missed the announce of the changes to come from a few months ago, so I only noticed that something was coming up over the week-end. Since the start of September is a common time for program changes on Radio (or TV) I wasn't too surprise ... but I wasn't really expecting the only radio I have been listening to since I moved to Canada 5 years ago, to change so much ... and not for the best, sadly.

So what happened you may ask? Well ... to sum-up, Radio 2 which use to be mainly Classical and Jazz, got stuffed with a large part of the Radio 3 playlists. Now don't get me wrong, there nothing wrong with Radio 3, in fact I have enjoyed it since the very first podcast of Grant Lawrence back in 2005, and I was also very disappointed when the fun take-over of Radio 2 airwaves by Radio 3 was terminated over a year ago (Saturday nights).

What's wrong then with Radio 3 taking over Radio 2? Simply put: wrong crowd, wrong time. Let's face it, the large majority of Radio 2's audience isn't the kind that will enjoy The New Pornographers at 7 in the morning ... I can understand that they will have wanted to expose the listeners to some of the new Canadian music, but a better approach will have been, IMHO, to bring minor tweaks to the programing by adding a single show composed of the usual Radio 3 playlist (e.g by shortening Canada Live) ... one hour will have been enough. In fact, the old Radio 3 show on Radio 2 (which I talked about earlier) was perfect to get folks introduced to the new Canadian music tree. Instead, we have 7 hours of it, and Radio 2 now just sounds like any other FM radios ... minus the ads that is.

At least, we still have The Signal ...