Thursday, July 9, 2009

Differences Between Windows and Mac Development

Well, after beating my head against a problem for like 6 hours today, I have finally gotten back to where I was... 6 hours ago. *sigh* Okay, it's not that bad. I do have some other work that happened in that 6 hours that's still around, but I made one change in the program and Bam! I felt like Elzar cranked my head up a notch with a spice weasel.
I was creating the character creation screens which are shown only if it's your first time running the game. I need to make it so that it's modal - meaning you can't avoid it - so I needed to do it before you had access to the tab bar. And things were going along well. I had a root view controller that was handling both character creation screens. I got my locations displaying for people to select where they wanted to start... It was going along great. And then... BAM! Spice weasel.
I had added the root controller's view to the main window as a subview. This seemed reasonable and rational and worked wonderfully. But I couldn't seem to remove it and add the tab bar. The tab bar simply refused to display. So I went down a whole clutch of rabbit holes trying to figure out a way to get the tab bar to display AND have the character creation pages come up. And then I managed to get so far down the rabbit hole I got stuck and couldn't find the way out. I hit up a friend of mine who's on Facebook - Don Metzler. He owns his own consulting business and we've known each other for almost a decade now. He's a Mac programmer AND a Windows guy, so he's familiar with the benefits and detriments of both platforms. He and I went looking at the code and tried to get it back to where it was semi-working. And, thanks to the chat, we got it back there. Yay.
What this pointed out to me, though, was one of the things that I really have to laud (that's approve) Microsoft for doing. They make all of the MFC (Microsoft Foundation Classes) available as source code. So when you're deep in the bowels of a combo box you can figure out why your particular hook isn't getting called, you have the proverbial snowball's chance to figure out why. With Apple, on the other hand, there's a sort of mystique to the internals. You don't get to know what happens in there and some things happen so automagically you can't possibly figure out how to replicate it.
Case in point: when you attach a tab bar controller to a MainWindow.xib file, there's some special magic that happens inside Apple's foundation code that hooks everything up. You get all of your view controllers laid out, the tab bar looks good, and things happen without having to write any extra code. If you try to replicate that, though, things kinda go south quickly. I found a few people online trying to do what I was doing (albeit slightly differently), but they ran into the same frustration I did. Had I access to the source, I could have replicated it and avoided the spice weasel. Instead? BAM! Spice weasel.
I've finally gotten back to where I was 6 hours ago in terms of the main game play. I need to spend tomorrow morning going through trying to hook up the character generation screens but at least they're done - I just need to get them to display and that will hopefully not involve a spice weasel and my eyes. :)