I’m sure the pun between the acronym for “NeXT Interface Builder” and this definition of “cocoa beans” is intentional, but it surprised me anyway:

I’m sure the pun between the acronym for “NeXT Interface Builder” and this definition of “cocoa beans” is intentional, but it surprised me anyway:

A watch might be one of the most common types of objects, but it remains also one of the earliest pieces of human craftmanship to show an extreme level of complexity, all contained in a small amount of space. Since the late 1700s, artisan watchmakers in Switzerland and elsewhere have shown their pride and skills creating watches called “Grande Complications”, containing thousands of individual parts and performing incredible functions:
The most complicated watch ever made, known in watch enthusiasts’ circles as “The Ultimate Watch,” is Patek Philippe’s “Calibre 89. The incredibly precise operation of 1728 parts in this really ultimate masterpiece of watchmaking allows to perform no less than 33 (thirty-three!) complicated functions, among them a correction for the 400-year-rule, an Easter date indication, a star chart, a tourbillon, a perpetual calendar, a sidereal time indication, and, and, and … This watch was sold in 1989 for the nice round sum of about four million Swiss francs.”
(Ozdoba, 2005)
(Source: CNN.com, 2005)
More information about the “Calibre 89″ can be found here and in the Patek Philippe Museum website.
However, the same watchmakers that made these fine pieces were also aware of the basic information that their creations were to provide: time. As such, their watches remained extremely easy to use, and they set up the basic standard for analog watches, in such timeless designs that the latest Swatch models show the same basic layout and functionality.
The underlying concept is the very same used in today’s object-oriented abstraction and encapsulation. Even Apple uses the idea of the watch to show this characteristic:
All programming languages provide devices that help express abstractions. In essence, these devices are ways of grouping implementation details, hiding them, and giving them, at least to some extent, a common interface—much as a mechanical object separates its interface from its implementation, as illustrated in Figure 2-1.
(Source: Apple Developer Connection, 2006)
In this article I will provide my view about how different OOP concepts apply to a real-life object such as a watch, in all its forms. Continue reading
(Highly geeky post ahead. You’ve been warned!)
I have found the very message that summarizes the beauty of Cocoa in a single word; see by yourselves, hereunder in line 47:
[source:c]
// The interface of a person @interface Person : NSObject { NSString* firstName; NSString* lastName; int age; } @end
// The implementation of the Person @implementation Person -(id)init { if (self = [super init]) { firstName = @”"; lastName = @”"; age = 0; } return self; }
-(void)dealloc { [firstName release]; [lastName release]; [super dealloc]; }
-(NSString*)description { return [[NSString alloc] initWithFormat:@”Name: %@ %@, %d years old”, firstName, lastName, age]; } @end
// Some code using the Person class int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableDictionary* dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setObject:@"Teto" forKey:@"firstName"];
[dict setObject:@"Rodriguez" forKey:@"lastName"];
[dict setObject:[[NSNumber alloc] initWithInt:34] forKey:@"age"];
Person* person = [[[Person alloc] init] autorelease];
// The beauty of Cocoa can be resumed to this very line:
[person setValuesForKeysWithDictionary:dict];
// Now sit back and relax:
NSLog([person description]);
[pool drain];
return 0;
} [/source]
This is an evening project that turned out to be really cool. Let’s say that you’re a Macromedia Flash designer, and your clients ask you to bundle your nice Flash movie as a screen saver. What to do? For Windows there are free utilities to convert a SWF into a screen saver, but not for the Mac – and the first commercial one costs around USD 200!
I propose here a simple solution for this problem:
The idea, then, is to bundle your own page, with your own movie, inside the screen saver bundle, and show the Flash movie this way. Easy said, easy done.
It all goes nice until… you try this solution :) The problem is, Flash movies loaded from “file:///” URLs are blocked by the built-in security mechanisms of Adobe… and you have to find a workaround for that. Mine was to follow the instructions on how to bypass the Flash security mechanism, and then create an installer package that will do what’s needed for you to enjoy the screen saver.
You can get both the project and the installer package in my projects section. I’ve tested the installer in three different machines, and it worked, so I hope it’ll work for you too :) Enjoy! As always, try this at your own risk. Murphy says that things can go wrong, so watch out.
![]()
Il y a de moments clés dans l’histoire de la technologie. Hier soir, vers 18h (heure suisse), il s’est produit l’un de ces moments. Apple a dévoilé un SDK (Software Development Kit) pour l’iPhone, et le monde du développement logiciel mobile ne sera plus jamais le même. Voici pourquoi.
There’s an interesting discussion going on these days on Ruby blogs about, basically, how to avoid one of the most common, annoying, easy-to-create bugs in any programming language: calling a method on a null reference (or pointer, depending on your language).
This single issue happens all the time, in garbage-collected and non-managed languages, static and dynamic, weakly and strongly typed; you have a handler variable “pointing” to an object, and before calling any methods on it, you’d better be sure that the object is there; you end up using assertions, “if” statements (and all of its variants), boilerplate code all over the place, when everything you want to do is to call that damn method. It’s frustrating, time-consuming and oh so common that we just try to not to think about it anymore. Continue reading
Lately I got curious to know how could I grab the entire desktop of my computer, and save it into a file, or display it into an NSImageView component. I started to look around on the web and discovered that:
I have found several useful resources in my quest, like this one, this other one, and finally this one. But what I wanted most was a complete application to play with, so what I did is to put all the different implementations I’ve found in one single application, called “ScreenshotDemo”:
Amazingly, the approach that seems the ugliest turned to be the most appropriate, that is, using an NSTask instance wrapping the /usr/sbin/screencapture utility. With it, the application feels lighter, easier to maintain, in the true, purest Unix style: using a collection of small utilities, all chained one to the other, is better than having an overbloated tool that does everything, but just bad.
You can just download the (universal) binaries and the source code from the ScreenshotDemo Project page.
By the way, for those that would like to do the same in C#, like me :) just check out this code. It isn’t much easier in .NET, as you can see ;)
And last but not least, here’s how to do it in wxWidgets, explained by Julian Smart, the creator of this incredible library.