Probably the best $90 spent


Posted by Jaime | Posted in Coding, Health | Posted on 09-12-2007

During the day, I am a programmer. And at night, I am a programmer and I am happy with that fact! However, at work, I have 2 Mac’s that have the ivory keyboard that Apple shipped with their computers prior to the new aluminum one and I am not happy with that. I used them for 4 months, thinking that it was just me and I needed some time to get used to them. However, I kept missing keys… and this drove me nuts!

Apple Ivory Keyboard 

“Quite your whining!” Okay, okay! I hear you! Why didn’t I do it sooner? Well I would have bought something sooner, but not too many Apple stores carry anything other then Apple keyboards and most of the Apple retailers where I live don’t carry much. So, by luck, I happened to be in Staples and they had a long rack of keyboards for me to fiddle with and to my surprise, I found the Logitech Wave Comfort on display and it was perfect. It comes as a wireless keyboard/mouse combo and it works great! Your hands are perfectly supported and the special buttons, all of them!!!, work as you would expect them to in Mac OS X Tiger and Leopard! 

Logitech Wave Comfort Keyboard 

I’m not getting any money from Logitech to write this review of their innovative and well designed keyboard, although I wouldn’t mind some, but the truth is… this is a great keyboard 🙂 If you are looking for something to replace your keyboard and are unhappy with what you’ve got, give this a try!  

Getting the datatype of an object


Posted by Jaime | Posted in Coding | Posted on 08-11-2007

In Java and C#, it’s really easy getting the datatype of an object that you are working with. If you don’t know what I am talking about, post a comment and I’ll explain it in more detail.Well anyway, surprisingly, I never had the need, until now, to do the same thing in C++. In other languages, you have the “typeof” keyword that allows you to get the datatype of an object.

This keyword exists on the Mac, but doesn’t do the same thing. To get the same type of functionality, you can use the “typeid” class to get the datatype and name of the object you are working on:

void GetMyType()


int i = 0;

cout << typeid(i).name();



Tell me how you really feel about GDB…


Posted by Jaime | Posted in Coding, Funny | Posted on 01-11-2007

I have some complaints about working with Xcode and GDB, but this guy had a mouthful to say: Click here. 

You know, most of us developers work on timelines that are already too short and the people mandating the schedules live in their own world, but this is something we all live with and having a debugger that takes time away from us is counterproductive.Apple has done a great job with their operating system, there is no denying that, but there is still some work that has to be done with their debugging tools. I’ve come from using Visual Studio, which is very reliable… I know, I know, the word reliable is usually not associated with Microsoft… ** cough cough ** red-ring-of-death!! ** cough cough ** blue-screen-of-terror!!! ** cough cough ** 

Uh-um… excuse me. Anyway, Microsoft has done a good job with their debugging tools and so shame on you Apple for letting your competitor shine where you should have. 

Using Subversion on Mac OS X, Part I


Posted by Jaime | Posted in Coding | Posted on 27-09-2007

The long and short of it
This article covers how to quickly install Subversion on a standalone Mac OS X workstation. If you are a developer who has used a source control program like CVS, and really don’t care about all of the different ways of setting up SVN, other than for personal development purposes, then this article is for you.

Some people want to get stared quickly and others enjoy the narrative. I have included both the long and short. The long narrative starts right after this paragraph. The short of it starts at the section titled, “How do I get started?”

The journey begins

Every wondered how to quickly set up Subversion, aka SVN, on your home workstation? I did, and it took me some time to figure out how to do it right. I’ve actually used Subversion at work and was able to set up the environment the way that most documents illustrate. When it came time to set it up on my home computer, I encountered a whole new experience that wasn’t pretty.

So, to save you some grief, I put together this article so that you can learn from my experience and maybe learn some things on the way. As with any endeavour, you should be careful of what you do on your computer. If you decide to install the software listed in this article, back up your computer first! This is common sense, but not too many people practice this until after the fact. So with that said, back-up your computer and come back when you are ready.

Save Your Butt
I’ve used CVS and SourceSafe in the past. Both programs use the same concept of source control where you have a central repository that stores a copies of your files in your project. You check out a file or whole projects onto your computer, do your work and the check those files back into the repository. The source control server then checks your files against what is in the repository, and depending on the options your have set up for your environment, asks your for additional bits of information, such as a log for the file commitment.

I’ve heard about Subversion from a fellow developer and I was intrigued. When this guy mentions a program, it’s usually good. After some poking around, I found that Subversion has a lot of nice features and some weird ones. SVN offers a really nice way of handling directories and tracing the history of those folders. Since I worked a lot with directories, SVN seemed like a good tool.

The Good, The Bad and The Ugly
I had the fortunate opportunity of installing Subversion at my office alongside CVS. The process wasn’t too painful: the documentation called for Apache to be installed along with WebDav components and this worked well on my server. The client computers used SmartSVN as a GUI client and importing projects into the server wasn’t too hard. SVN seemed quicker than CVS and worked very well over SSH connections.

I also had the unfortunate opportunity of setting up SVN on my home computer. All of the documentation available stated that you need to use Apache to have the clients work with the SVN server. So, there I was trying to figure out how this would actually work on a standalone computer. I couldn’t find anything that showed a single workstation set up and I even tried installing Apache with WebDav on my home computer. This just didn’t make sense! There are a lot of developers that work on their on computer and use that same computer for versioning their work. CVS of course made it very easy, and SVN seemed like the opposite.

So what happened? I did a lot of reading, that’s what happened. I haven’t done this much reading since I first learned C. To me, a source control program doesn’t seem like something that should require so much research, but times have changed and so have the tools.

How do I get started?
So enough talking and let’s get down to business. Here are the steps that you need to take to install a standalone version of SVN on your own computer along with a client that allows you to check out/in your project files.
Step 1: Download the software
This goes without saying. But what do you need? You need the following tools:

1. Subversion, aka SVN, can be found at
2. [Optional] A good graphical tool like SmartSVN

Step 2: Install the software
Mac OS X
These instructions came from the Apple Developer Connection site,, but here is my shortened version:

1. Download the source files from:
2. Open the Terminal application, found in /Applications/Utilities/.
Extract the zip archive:

$ cd ~/Desktop
$ tar xvfz subversion-1.4.5.tar.gz
$ cd subversion-1.4.5

Compile the source code:

$ ./configure –prefix=/usr/local \
–mandir=/usr/local/share/man –with-ssl \
–with-apxs=/usr/local/apache2/bin/apxs –with-zlib \
–enable-swig-bindings=no –without-berkeley-db \
–with-apr=/usr/local/apache2 \

Run the make command, and then run the sudo make install command:

$ make
$ sudo make install

Add the ‘/usr/local/bin’ path to your profile:

$ cd ~
$ echo ‘export PATH=”$PATH:/usr/local/bin”‘ >> .profile

If you don’t want to go through that trouble, you can run the following shell script on your computer:

Step 3: Create a repository
This can be the confusing part. In a version control system like CVS, you have a single repository where all of your files and their versions are kept. In Subversion, you can have one repository for all of your projects, or you can create a repository for each project or a combination of both. I took the way that I am most familiar with and created a single repository for all of my projects. To create a repository, you type the following command in the Terminal App:

$ svnadmin create /path/to/your/repository

The repository can be anywhere you like. If you want to place a folder named ‘SVN’ in a Development folder in your Documents folder, you would type in Terminal:

$ cd ~/Documents/Development

$ svnadmin create SVN

The last command creates the SVN folder and all of the items in it to support the Subversion repository. You can name the folder anything you want; you don’t have to use SVN as the name of the folder.

Now that you have a repository, it’s time to create some folders for each project…

Step 4: Create folders for each project and import
So, to create a folder for your project, type in this command in Terminal:

$ svn mkdir -m “Creating project folders” file:///Users/yourname/Documents/Development/SVN/MyProject

You can repeat this command for however many folders you need to create. To create multiple folders at one, you can separate each path with a backslash:

$ svn mkdir -m “Creating project folders” \

file:///Users/yourname/Documents/Development/SVN/MySmallProject \


To import your work into any of the folders you created, you can import your code using the following command:

svn import /path/toyour/projectfolder/MySmallProject file:///Users/yourname/Documents/Development/SVN/MySmallProject \
–message ‘First time project import into Subversion’

Just like any version control software, you have to check out the project before you start to work with it:

cd /Users/yourname/Documents/Development/CPP/
svn checkout file:///Users/yourname/Documents/Development/SVN MySmallProject

Notice that I first changed directories to a CPP folder. When you checkout the project for the first time, Subversion is going to copy all of the files from the repository into a new folder named MySmallProject in the CPP folder. That is a one time thing: every time you check out the project afterwards, Subversion will check the version of the file that is in that directory and do an update where necessary.

Maybe by now, you are saying to yourself that this is too much work. Well, that is were graphical tools come in handy..

Step 5: Explore Subversion with SmartSVN
SmartSVN is a great tool for working with your repository. It gives you a graphical view of your file history and allows you to see what files have changed. In the next installment, I will show you some basic commands using SmartSVN and how to use Subversion with Xcode.

Till then, happy coding!

Using Cocoa to resolve Unix file paths with tildes


Posted by Jaime | Posted in Coding | Posted on 30-07-2007

Quick! How do you expand a file path that has a tilde in a program? Luckily, you can use NSString to resolve the path for you. So, if you path looks like “~/Library”, you can use the stringByExpandingTildeInPath method to resolve the tilde to the full path: “/Users/johndoe/Library/”. Here is s snippet of code to show that:

NSString *myString = [[NSString alloc] initWithString:[@”~/Library” stringByExpandingTildeInPath]];

Of course don’t forget that you need to allocate memory for the string and initialize it! Now, if you need to use this function within a C++ App, don’t fret. You can add the above listed code to a C++ file and so long as you set the file to compile as a sourcecode.cpp.objc file,in the File Type drop down list in the “Info” dialog box, you should be good to go.

Click here for the Objective-C project

Objective-C and C++: Friends or Foes?


Posted by Jaime | Posted in Coding | Posted on 16-07-2007

For many developers like myself, I learned a language as a means to create a program on a specific platform. Back in the early 90’s, I learned Pascal because that was the language that PC and Macintosh’s used. Later in the 90’s, I learned C++ because this was the buzzword language that BeOS, the powerful multimedia rich operating system, used. I learned other languages throughout my career, like Java and C#, but none has stood out more than Objective-C.Objective-C was used by NeXT and later by Apple when NeXT was acquired by them in 1996. Apple needed a next generation operating system badly and they needed one that was easier to develop for than Mac OS 7. Truthfully, programming on the Mac early in my career was a painful experience, littered with bugs, crashes and painful debugging sessions. Pascal as a programming language was not fun for me. C++ in MetroWerks looked really cool, but a program made with the PowerPlant library still had problems because of the nature of Mac OS 7.

When Windows 95 came out, Microsoft introduced an easier way to create programs for a platform. I got sucked into MFC, which was built in C++, and I created programs as soon as I learned how to subclass CWindow.

So how does this bring me here, to Objective-C and Mac OS X? Well, when Steve Jobs came back to Apple in 1996, he brought into the company one of the greatest accomplishments he and his team at NeXT created: an Objective-C based framework named OpenStep. Although Microsoft had MFC, which seemed so much better than programming with the Win32 API, OpenStep, later renamed Cocoa, was a radical departure from conventional object oriented programming.

MFC, which stands for Microsoft Foundation Classes, was built in C++ and allowed developers to create programs using reusable modular code and event messaging. A dialog class would respond to messages sent to it via a series of macros created by the compiler. Those who are familiar with programming with MFC and Visual Studio know about the event map macros. Objective-C and Cocoa were different in that you didn’t have to create a subclass in order to gain functionality in a particular module, or that you didn’t have to worry about sending a message to an object method that doesn’t exist. You see, for those who didn’t catch that last statement, that is probably one of the biggest distinctions between Objective-C and C++. In Objective-C, you are actually sending a message to an object. Even if the method doesn’t exist in the object, that’s ok in Objective-C. In MFC, built around C++, you are actually calling a function. In order to call that function, you must first declare it somewhere in your code. Messages aren’t really sent to objects in C++, but many frameworks create message-like mechanisms by storing an array of functions that would respond to a particular message posted to an event class. This is what MFC does when Visual Studio embeds your code with macros that insert extra event functionality.

So, I am assuming that if you have read the article to this point that you are most likely a C or C++ developer who is looking into Objective-C and trying to understand it more. If you were like me, you probably bought the Objective-C book published by Apple or downloaded the PDF( available from the Apple Developer Connection and either forced yourself to learn the language and accept it or gave up on trying to understand it altogether. If that is the case, I don’t blame you for feeling a little lost. Honestly, I felt that same way too. I learned the language and I compared it to every other language that I have learned, wondering why Apple choose such a strange language. When Cocoa became available in Java, I headed down that path since it is more like C++ and much more familiar to me than Objective-C. However, I quickly learned that programming with Java and Cocoa was not optimal for me or for my projects.

The first problem was that I really didn’t understand Objective-C. The second problem was that I constantly compared it to C++, thinking it was weird. The solution to both of these problems was understanding how Objective-C worked and not comparing it to C++. The first and most important attribute to learn about Objective-C is that programs built in this language can have dynamically loaded code. You might think, “big deal! I can do that with a DLL!”, but what you don’t realize is the mechanism that sits behind DLL usage: in order to use a DLL, you have to reference the DLL in your project and link you application to it via the compiler. When you compile your application, the compiler links the code into the binary executable, effectively copying the code into the application. Even if you are using a dynamically linking the library, there is only a reference to the DLL on the file system, however, if the DLL is different or missing, your application will not launch. In Objective-C, you don’t have to link to a library at compile time: you can wait until your program is running to load the library and call the functionality that is inside of it. If the library is different or missing, your program will still launch and execute.

This is hard for a lot of developers to understand, but this is similar to the COM interface in Windows. You can call invoke code within another file using an Interface class to understand the contents of that code. Objective-C is built around the Interface concept, which is evident when you declare a class in Objective-C: class declaration has 2 parts: the interface portion (in the header file) and the actual code declaration part(in the implementation file). In C++, you would declare a class as follows:

class MyClass



int _someVariable;


int _someOtherVariable;


MyClass(); // constructor

~MyClass(); // destructor

int CheckCPU();

int CheckHardDisk();


The CheckCPU function would be coded in a separate .cpp file as follows:

int MyClass::CheckCPU()


// do some work

return 0; // return an int


Objective-C is a little different: 2 keywords are used in the declaration of a class and the implementation of the methods: @interface and @implementation. To declare the above listed class in Objective-C, you would type the following:


@interface MyClass : NSObject {


// declare my class variables


int _someVariable;


int _someOtherVariable;



// declare my class methods






To implement the CheckCPU function, you would type the following:

#import “MyClass.h”


@implementation MyClass




// do some work

return 0; // return an int




Notice the usage of @interface in the .h file and @implementation in the .m file. Each one of the keywords is terminated by the @end keyword. It’s different, but very powerful!

At first glance, what might also seem odd is how methods are built. When you look at them, they look like typecasted C variables:


The minus(-) sign in front of the method indicates that the method is an instance method. Obj-C uses a plus sign (+) to indicate that a method is a class method. An instance method is one where you have to create a new instance of a class in order to use the method. A class method is like a static function in C++ where you don’t have to create an instance of a class in order to use the method.

Objective-C is a simple language that can be learned in a day. However, if you are a seasoned C++ developer, you might find it hard to absorb Objective-C and accept it. I have worked with Objective-C and Cocoa for quite some time now and there is a lot of good reasons to use this combo in your next Mac OS X project.

Now, I’m not saying that Objective-C is the end-all language, but it is certainly very impressive. Although there are a lot of features that C++ has that Objective-C doesn’t have, Apple certainly has made up for some of those lacking features in the frameworks they have built. For those of you like me, where you have written a ton of code in C++, there is good news. Most of that code can be reused in your Mac OS X project since applications built in Cocoa/Objective-C can call C++ code as well. Although Objective-C classes cannot inherit from a C++ class, it is good to know that you do not have to scrap your code for this awesome programming language.

Take a look at the resources listed below and the articles listed on There are sample projects listed on the website showing you how to use C/C++ with a Cocoa project and likewise, articles to further educate you on Objective-C and other topics related to the language. Once you start effectively working with the language, you will understand why it has become such a popular language in the developer community. Happy coding!

Additional Resources:

Creating Thumbnails in a List View Control, Part 1


Posted by Jaime | Posted in Coding | Posted on 30-06-2007

A long time ago, I needed to create an application in Windows that could enumerate the contents of a folder and present the images as thumbnails within a List View Control. I had found this article on that promised to show how to do all that, but actually created nothing more than confusion. There were a couple of classes listed on the website which showed how to use Threads to load images, but the classes were incomplete and there was no sample code provided. If you actually check out the article, you will see a long listing of comments dating back to 1999 of developers asking for sample code. It’s kinda sad to read because with this much demand, you think that someone would answer their requests. To add insult to the injury, I had actually tried to get in contact with the author, but the email bounced back to my inbox, stating that the email address does not exist with the ISP…

Well, with the options laid out in front of me, I did what any other ambitious developer would do: I tried to reverse engineer the application based off of the principles of the article. Now, while I was doing this, someone had actually emailed me code, stating that it was sample code from the website. My eyes widened when I first saw the email and thought to myself, “ALRIGHT!!! Now I can move on with my life!”. I raced to download the zip and unzip it to my desktop, which of course was my favorite repository for developer code… cough cough, and after waiting feverishly for 15 seconds for the files to unzip and for Visual Studio to open the first file, I realized … this wasn’t the code from the author on the website. What was going on here?

It was a completely different application, which also displays thumbnail images in a list view control, but nonetheless different. It was created by a different developer and had code contributed to it by several other developers, none of which I think are related. However, the code works and it does do what it advertised to do.

Now, since this code was freely given to me and no one has laid claim to it, it seems appropriate that this code base be used for educational purposes. So here it is! Download your copy of the code that was sent to me that promised to display thumbnail images in a list control.