Archive for August, 2010

I bet you have been wanting to put your own custom ringtones on your iPhone, free of charge, for quite a while — I have a solution for you.

Ever since I got my first iPhone, I have found the lack of easy custom ringtones to be quite a pain. Apple will tell you to use iTunes if you wish to rip a piece of a song and use that as your ringtone, however they will charge a small fee for that and only a select few of the iTunes store songs are eligible for ringtone creation — in other words, their solution is not very handy, at all.

The Solution
It is actually quite simple and I don’t really know why I only just found out about this, but it seems GarageBand does the trick for us and you are not constricted to use song rips with this approach.

Open up GarageBand and create a new project, set the loop bar to 40 seconds or lower (this is the time limit of ringtones on the iPhone). Over the span of your loop, start creating your very own ringtone, and when you are happy with your marvelous creation go to the menu ‘Share’ and click on ‘Send Ringtone to iTunes’. Sync your iPhone and voila!


Review: iPhone 4

Posted: August 23, 2010 in Reviews
Tags: , , , ,

So, I have had the iPhone 4 for about two weeks now and I’d like to share my impressions of it with you guys, in an effort to separate nonsense from the facts about it.

First Impressions
When you pick up this phone and turn it on, you immediately notice the astonishing ‘Retina Display‘. The pixel density of this display is incredibly beautiful, but more importantly it makes a lot of things work better on such a small display, like e-book reading, internet surfing, etc. — Initially I thought this feature to be purely for looks, but found it to be much more than that.

There has been a lot of chatter around the antenna design of the iPhone 4 and it has been pointed out as a technical flaw. In my experience, this has been blown completely out of proportion, as I have had no problems with it at all — in fact, the very first call I made from my iPhone, I held it in the so-called ‘death-grip’. There is some truth to the fact that it drops in signal strength when held in a certain way, however this doesn’t affect whether or not you can make a call, as long as there is at least one bar left.

Why Did I Get It ?
My old iPhone 3G was beginning to feel a bit sluggish whenever I wanted to try out new things that were slightly more CPU intensive. I also really wanted a video-capable phone, for the occasional YouTube upload, and the iPhone 4 fits the bill quite nicely with 720p recording.

If there is anything I did not cover, that you would like to know about, please leave a comment and I will update the post as soon as possible.

Retina Display

Posted: August 22, 2010 in Thoughts

With the incredibly dense ppi of the new iPhone 4, will we we this filter through to the Mac? — I definitely think so.

Sooner or later, we will see an industry-wide transition from standard ppi to “HD-ppi”. However, there are a few technical issues with handling the transition, the most prominent of them being the content that already exists. If the ‘Retina Display’ pixel density of the iPhone 4 were to be applied to say a Macbook Pro 15.3” screen, like the one I have, I would probably not be able to see what is going on — everything would become very tiny, the resolution would have gone up by over a factor of 2. This means that whenever this is going to happen, the transition won’t be easy in comparison to the HDTV transition, as the entire web would have to account for this change.

I’ve never really used the Interface Builder all that much when developing, and frankly I don’t like the “magic” it does for me. I prefer being able to visualize what my application does in the code by avoiding the NIB altogether — and I’m going to show you how I go about doing this.

Why ?
Well, there are projects where it just doesn’t make sense to use Interface Builder, rendering the NIB obsolete to the project itself. This is true for projects that have little or no GUI based on the AppKit, like fullscreen games. Games in particular usually incorporate their own GUI, which is managed by the engine.

How ?
As far as I know, there is no Apple-sanctioned method of approach of doing nibless development under cocoa, and the method I will show you is probably not the only way — or the best, for that matter.

The standard main.m looks something like this:

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[]) {

    return NSApplicationMain(argc,  (const char **) argv);

The return NSApplicationMain(argc, (const char **) argv) instantiates your application by creating the singleton object NSApplication, loading the MainMenu.xib (the nib) and calling the run method on your NSApp. In order to avoid the nib, we need to circumvent this by initiating the application ourselves.

The first thing we do, is to get rid of the NSApplicationMain function call. In it’s place we simply return zero, as cocoa will call exit() before reaching the return instruction of the main function, so this never gets executed anyway. Now that our main function looks like a generic C program, we can begin recreating what the NSApplicationMain did for us.

We will need to wrap everything in an autorelease pool, and make sure we have an instantiated application — we do this as such:

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
    // create an autorelease pool
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    // make sure the application singleton has been instantiated
    NSApplication * application = [NSApplication sharedApplication];
    // drain the autorelease pool
    [pool drain];
    // execution never gets here ..
    return 0;

Now that we have made sure we have an application to run, we can go on and create an application delegate — if not already present in your project.

Create a new Objective-C NSObject subclass, name it AppDelegate. In the @interface section found in the header of your new NSObject subclass, add the NSApplicationDelegate protocol to it as such: @interface AppDelegate : NSObject <NSApplicationDelegate>

Import the AppDelegate’s header to your main.m as such: #import "AppDelegate.h"

Now that your AppDelegate implements the NSApplicationDelegate protocol and your main.m knows about it, we can create an instantiation of the application delegate and assign it to the NSApplication, and then all we really need to do is to call the run method:

#import <Cocoa/Cocoa.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
    // create an autorelease pool
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    // make sure the application singleton has been instantiated
    NSApplication * application = [NSApplication sharedApplication];
    // instantiate our application delegate
    AppDelegate * applicationDelegate = [[[AppDelegate alloc] init] autorelease];
    // assign our delegate to the NSApplication
    [application setDelegate:applicationDelegate];
    // call the run method of our application
    [application run];
    // drain the autorelease pool
    [pool drain];
    // execution never gets here ..
    return 0;

This takes care of the main function. Now all we need to do, is implement how our application delegate handles our application. You can handle this however you want, I’m just going to show you how to create a window with a content view. Keep in mind, that for the sake for keeping the demonstration short and to the point, I do not use custom classes for these, in real projects I would definitely write a class for the content view.

Inside of the class declaration of the AppDelegate, we put an NSWindow and a NSView as such:

@interface AppDelegate : NSObject  {

    NSWindow * window;
    NSView * view;

Because the AppDelegate implements the NSApplicationDelegate protocol, there are quite a few methods that it will now respond to and that will get called during run-time. So in the definition of our application delegate, we add the following methods and implementations as such:

@implemention AppDelegate

- (id)init {
    if ( self = [super init] ) {
        // create a reference rect
        NSRect contentSize = NSMakeRect(0.0f, 0.0f, 480.0f, 320.0f);
        // allocate window
        window = [[NSWindow alloc] initWithContentRect:contentSize styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES];
        // allocate view
        view = [[NSView alloc] initWithFrame:contentSize];
    return self;

- (void)applicationWillFinishLaunching:(NSNotification *)notification {
    // attach the view to the window
    [window setContentView:view];

- (void)applicationDidFinishLaunching:(NSNotification *)notification {
    // make the window visible.
    [window makeKeyAndOrderFront:self];

- (void)dealloc {
    // don’t forget to release allocated objects!
    [view release];
    [window release];
    [super dealloc];


.. and that concludes my approach of doing nibless development. Notice that I did not implement the main menu, so when you run this the main menu will not work. But there is a solution for that as well, I might write an article about that some time — please do let me know if this is something you would like to see.

Phew, that got a little lengthier than I originally expected it to.

Hopefully you found this useful. If you have any questions or thoughts on this, please leave a comment — Thank you.

Download Xcode Project
I’ve made an xcode project available for download at, just click the link above to get it. It has been build, tested and it works.

UPDATE Fixed a typo; in AppDelegate.m it said ‘@implemention’, while it should have been ‘@implementation’. Thank you albert7546, for pointing out the source wouldn’t compile.

Adobe makes great products, and Flash is definitely one of them. I used Flash back in the day when it was very popular on the internet and I loved using it, web-content became an interactive experience with very little effort. However, my vote is not for dying technologies and Flash is indeed living its lasts days.

I can understand why Adobe is struggling to keep Flash alive as it has been playing such a major role in the industry — and for so long that this may have come as a shock for Adobe. And while they probably won’t let Flash die without a fight, I do not think they will succeed in keeping it alive for much longer.

The Apple Issue
On this matter, we supposedly have two sides of story to worry about; the end user and the ethical aspect of Apple not implementing Adobe’s technologies.

Besides the drastic movement by Apple to simply cut out Flash from its iDevices, I don’t think the average end user will ever really notice the transition, as long as the content they enjoy is still available to them. Flash is easily substitutable by several other —and newer— technologies, and as Apple points out, HTML5 is indeed a great substitute. In the end, transitions usually pave the way for new exciting things and the battle of who takes over the main stage when Flash dies is on — my bets are placed on HTML5 and WebGL.

I do think Apple could have handled this with a little more professional courtesy, however I understand and appreciate their move, even though it was a little out of line. Adobe provides some of the most important applications for the Macintosh platform and Apple needs to recognize and cherish that, so this was a very bold move to make as it could potentially hurt a great partner.

All in all, Adobe I’m sorry for your loss and Apple … behave!


The C Programming Tutorial is now done. I spend most of yesterday and this morning writing on this, hoping to finish it some time this evening. However, it seems that I almost completed it this morning. There are only a few lessons missing, but don’t worry, I expect these to be the conclusion of it, so it is all set for you to start learning C. These last lessons will be concluding what you have learned and bringing it all together in a project — a game, your very first game.

I hope you will enjoy the series, as I put a lot of effort into making the lessons as understandable and straight-to-the-point as I could. Hopefully you’ll be writing C fluently in no time. If this tutorial yields success, I will continue to add more lessons, getting into more advanced topics.

If you do follow along with the lessons, please comment on the lessons if you had trouble understanding it, if you have questions or pretty much anything you would want to share or ask. I will make changes if necessary and provide you with answers, should question arise.

Happy coding, have fun! 🙂