haniblog

Icon

Flame Artist by day. Proud Dad by, uhm, the rest of the time. Lover of everything Apple. Hater of everything Microsoft. Except for the Xbox 360 of course.

And Then There Were Three

Finally, the iPhone has more than one network in the UK. Two days ago Orange announced that they’ve broken O2′s stranglehold on the iPhone and will be selling all models by Christmas. Yesterday Vodafone declared they will be selling the iPhone as well from early 2010.

What will this mean to the iPhone? Considering that Apple recently reported that there are over 85,000 apps in the App Store and over 2 Billion downloads in its first year, those numbers will now skyrocket. There has never been a better time to start writing apps for the iPhone and the Mac platforms.

I’ve been dabbling with Xcode for a little while and found some really good resources to help me get started. The best guide so far has been BecomeAnXcoder and I highly recommend Aaron Hillegass’s book Cocoa Programming for Mac OS X. When you have a handle on Xcode and want to get started on iPhone development, there’s Stanford University’s excellent iPhone Application Programming podcasts.

Do it now if you can. The iPhone application market is about to expand massively.

Adobe CS5

According to John Nack, Photoshop’s Principal Product Manager, all Adobe CS5 applications will be fully 64-bit on OSX! There will not doubt be tons of new features but I’m very impressed with what will go into Photoshop as you can see from this technology demo:

And Adobe will finally kill their incredibly hostile installers and use Apple’s robust PKG format. To add icing on the cake, the licensing errors that many people faced is due for a change as well. With CS5, product licensing will not stop the application from launching and will display a serial number re-entry interface.

The product suite is slated to be released in April 2010.

Cool Stacks view

Since the update to Snow Leopard I find myself using a feature that was introduced in Leopard which I never used very much: Stacks. Finally, I can navigate the hierarchy of a folder or drive in the Dock quickly and easily. In Leopard I usually switched to the View as List option and avoided Stacks altogether. Thanks to this hint on MacOSXhints.com I now have a hybrid view which I really like: a navigable list which looks slick.

Just type this in the Terminal and you’ll see what I mean:

defaults write com.apple.dock use-new-list-stack -bool YES; killall Dock

Click on the image above for a full-sized view. Of course if you’d like to switch back to the default view just replace the YES to NO in the command above.

Graphic Novels

The last few posts here have been very tech-heavy and I feel I need to redress the balance a bit. For years I’ve been an avid Graphic Novel reader… okay, call them grown-up comics if you want to! I still find myself re-reading The Sandman every few months and I must have bought the series a decade ago. Other favourites include a Sandman-offshoot character, Lucifer, pictured above, and Preacher. And let’s not forget the fantastic Watchmen series.

I do have the actual books themselves but also have digital versions on both my iPhone and MacBook Pro using two similar comic viewers: ComicZeal on the iPhone and ComicBookLover on the Mac. Both applications have utilised the best features of the platforms they run on. If I want to have a single page-view on my Mac, I turn the laptop over on its side and ComicBookLover will present the perfect view, thanks to the built-in accelerometer. On my iPhone, ComicZeal will let me zoom in and drag along the panels to read the story. Highly satisfying.

First app: Count Characters

So SimpleWord is a little bit advanced at this stage. I started with one of the first challenges in Cocoa Programming for Mac OSX, a simple application that counts characters in a line.

The window should have a text field where the user enters a string of characters, a button which tells the application to count the characters and a label to display the result. I started with creating a new Xcode project called CountCharacters and in there I created a new class and called it AppController. In the header file AppController.h file I declared the following:

@interface AppController : NSObject {

IBOutlet NSTextField *input;
IBOutlet NSTextField *output;
}

- (IBAction)countIt:(id)sender;

@end

The first line creates an instance of NSObject and declares two outlets: input and output. When the user clicks the button, it triggers an IBAction method called countIt. With that done, I created a simple UI in Interface Builder:

Then it was time to make the connections in Interface Builder. I created a new Object in IB, called it AppController and assigned it the same class. I set the input and output outlets to the new object and set the action of the button to the clickIt: method.

Back in Xcode, here’s what I coded in the implementation file AppController.m:

#import “AppController.h”

@implementation AppController

// Set the output text label to ??? on first run
- (void)awakeFromNib
{
[output setStringValue:@"???"];
}

- (IBAction)countIt:(id)sender
{
NSString *string = [input stringValue]; // Get the value of input
NSInteger count = [string length]; // Get the length of string

NSString *display = [NSString stringWithFormat:@"'%@' has %i characters.", string, count];

[output setStringValue:display];

}

First, awakeFromNib changes the Label field in the window to ??? when the application first runs. The countIt method was simple to put together despite stumbling on some syntax. The string instance variable, or ivar, gets the value from the input field in the application and the count ivar returns the length. The display ivar is formatted with the resulting output. The last line changes the label in the window from ??? to the value of display. Here’s what it tooks like:

Beginning with Xcode

For the past few months, I’ve been dabbling with programming on the Mac but I haven’t had the time to really dive in. I was trying to explain to someone how it worked and realised that I couldn’t really articulate how. Therefore, this will be a series of posts on how I intend to build applications using Xcode, Apple’s free development environment.

There are plenty of excellent guides but I found that they all had one flaw: obsolescence. I would be following a guide until it reaches a point where the window, method or button isn’t there in my version of Xcode. And I come to a screeching halt. Lots of the guides have been written for previous versions of Xcode and haven’t been updated.

Again, I intend to document my journey through development on my Mac and iPhone. I’ll start with writing a simple word processor, SimpleWord.

Quicktime X and MKV files

I was a little bit disoriented with Quicktime X, to be honest. What, no export preferences? Only Sharing to iTunes? The UI looks very nice and the promise of GPU-accelerated playback is theoretically good, but what about 1080p MKV files playing natively? Quicktime X doesn’t recognise anything besides MP4 or iTunes’ M4V files. Perian was a constant presence in Leopard but a second-tier citizen with 10.6. Until now!

Thanks to the info in this thread on the cocoa forge board and the latest version of Perian, this utility will let Quicktime X recognise and play .mkv files. Front Row will happily play AVI files (as long as you have Flip4Mac installed) and SD MKV files but not 720p or 1080 movies unfortunately.

Of course, there’s always Plex which plays all movie codecs flawlessly without the need for Perian.

Back from the dead

Finally! It took a few days and loads of DNS issues with my ISP but haniblog is back online. I might write a post on the saga at some point but I’m happy to say that normal service will resume!

UPDATE: Looks like there are still some problems with the site. Doh!

UPDATE II: Looks like everything’s back except for a few comments. Let me know if anything else is missing. Phew, that was tough!

The Curious Case of Quicktime Autoplay in Safari

Ever since I installed Snow Leopard, I’ve been battling with a strange bug in Safari. If I go to a website with several embedded videos, they all start playing simultaneously. I’d been in the head of the page with no video present in the current view when suddenly all the audio streams start playing and overlapping each other. Cue heart attack. Here’s what happens:

I’ve been searching Google, combing the Apple discussion boards with no clue or direction on how to fix this bug. Then this morning I had an idea. I thought it must be a Safari plugin… and it was. I’ve been using a flash blocker called ClickToFlash and it was the culprit. When it intercepts YouTube videos it sets them all to Autoplay and they all start playing. Thankfully, it’s been reported as a bug in the ClickToFlash support board.

Once I removed the plugin from the ~/Library/Internet Plugins folder, Safari behaves normally as seen here:

UPDATE: As I mentioned before, there is a support ticket to fix the autoplay bug in ClickToFlash 1.5fc2 and there is now a workaround as well. In the ClickToFlash Settings window, make sure Load H.264 Videos from YouTube is unchecked.

Hi. I'm Hani and this is my blog. I also have some photos on Flickr, bookmarks on Delicious, tweets on Twitter and generalities on Facebook as well. Most of the time I can be found at Prime Focus in London, crafting commericals using Flame.

Conversationalists