Tuesday, October 25, 2005

Graphical Editing Framework for Cocoa

For my apprenticeship I am working on a project in Java in the Eclipse framework. Because we're working on a visual editor we make use of GEF (Graphical Editing Framework). The documentation for this is rather poor, but that's not the point of my post.

Now I have been searching for a similar framework in Cocoa, but haven't found anything. So here comes my mad megalomanic idea. Let's start a project on sourceforge to make our own framework, based on GEF. Of course making use of the idiosyncrasies of Objective-C and Cocoa, instead of the Java stuff in GEF.

I really believe such a project could provide a boost in Cocoa application development. Some input from other developers would be nice.

Mind, that I currently don't have time to immediately start something like that. Just some thoughts and dreams for the moment.

References:
Eclipse: http://www.eclipse.org
Gef: http://www.eclipse.org/gef/

Tuesday, October 04, 2005

Localized strings with a specified localization

I have been searching for a way to get a localized string for a specified localization for some time now. Finally I have found the solution. Well to be honest, I was given the solution by a certain Douglas Davidson on the CocoaDev mailing list. Thank you very much Douglas!

Here's the problem: Assume you have an application which has multiple localizations, but needs to access the localizations besides the preferred localization of the user at runtime. A simple example could be an App that I am currently working on, which among other things prepares exams for teachers. Those exams could be in a different language than the one the program is currently running in. I would like to use something similar to NSLocalizedString for the static text on the exam.

After finding out this wasn't provided by NSBundle in Cocoa yet, I have decided to make a category which adds support for this.
The important thing here is the macro NSLocalizedStringForLocalization. This is essentially the same as NSLocalizedString, except that you can specify the localization you want. Check out the code:
NSBundle_Extensions.h
NSBundle_Extensions.m

[update] The strings dictionary is now cached
[update 2] Fixed bug explained in comments by Jonathon

Tuesday, August 30, 2005

Delirium Tremens




I've tried out a new beer today called Delirium Tremens. It's brewed in Melle (Belgium) which is actually only 10km from where I live. I must say it's a real shame that I didn't try it out any sooner. This is really A-class beer.

I like it so much I decided to do some research on it, and it turns out that this beer has been elected as best beer in the word in 1997. The description in the image is true poetry and I could only say amen to that.

Monday, August 29, 2005

Logging method invocations in Objective C

Here is a code fragment I use to log method invocations in Objective-C. The great advantage of Objective-C is that you can find out what the name of the method is that is executing. I don't believe this is possible in a language like Java.

QSLogMethodInvocation macro
// Prints a line in the console stating the name of the
// method that is invoked.
//
// For example if class Foo has a method bar, the definition
// of bar in the class Foo could contain QSLogMethodInvocation().
// The following message will be logged: Invoked bar from class Foo
#define QSLogMethodInvocation()\
NSLog(@"[LOG] Invoked %@ from class %@",\
[NSString stringWithCString:(char *)_cmd], [self class])


QSLogAbstractMethodInvocationError macro
// Prints a line in the console stating an abstract method
// was invoked.
//
// For example if class Foo has an abstract method bar,
// the definition of bar in the class Foo should contain
// QSLogAbstractMethodInvocationError().
// The following message will be logged:
// Error (Foo): abstract method bar invoked
#define QSLogAbstractMethodInvocationError()\
NSLog(@"[LOG] Error (%@): abstract method %@ invoked",\
[self class], [NSString stringWithCString:(char *)_cmd])

First post

Here is the classical first post.

Welcome to my blog! I will be writing some information about my private and professional life on this blog. This will mainly be about development of Cocoa applications and my studies.

Hopefully this will grow out to be a fun and resourceful venture for me and you readers.

I am pleasantly surprised by the clean interface of blogger.com. Last year I had a project to develop a blogging application, as a project for my studies, with a group. The results are visible on this site: se5_2005. Upon request I could start up the blog portal application itself on the server.