Archive for the ‘Cocoa’ Category

GrandPerspective 0.97 Universal

Wednesday, November 15th, 2006

A new version of GrandPerspective has been released. I downloaded the source, configured a project and did another universal build which you can download now.

GrandPerspective 0.97 Universal Download

Note: I only did a build of GrandPerspective. I’m not involved in any means in the development of GrandPerspective. Therefore I can not help with any bugs in there :)

Data for a custom cell in a NSTableView

Saturday, November 4th, 2006

Creating a good looking interface is a lot of work. There was some discussion lately about the Human Interface Guidelines (HIG) and when you should break them. Daniel Jalkut has written a very nice blog entry on how he introduced his own HIG in order to improve the UI of FlexTime.

I’m not an UI designer. I get most of my ideas from playing around with other applications. One thing I learned when extending the UI is that it could take a lot of time to do so.

Inspired by the user interface of NewsFire, Mail, iPhoto, and others I wanted to display an icon and two lines of text in a single table column. (more…)

NSPredicate: The integrated query language

Tuesday, October 24th, 2006

Often it’s hard to keep up with the all the new cool stuff. Java 6 is around the corner and only one of my projects already uses Java 5.

The same is for Cocoa. Apple is finishing Leopard while I’m still learning APIs and enhancements of Tiger. So was it today when I remembered something from the WWDC that’s called NSPredicate.

In order to find out if an application with a specific bundle identifier (unique key) is running you would do something like this:

int index;
NSArray* apps = [[NSWorkspace sharedWorkspace] launchedApplications];
for(index=0; index < [apps count]; index++) {
    NSString* identifier = [[apps objectAtIndex:index] 
                    objectForKey: @"NSApplicationBundleIdentifier"];
    if ([identifier isEqualToString: someIdentifier]) {
        // do something and leave for loop            
    }
}

Tiger introduced NSPredicate which is used by core data to define queries. But it can also be used to search for items in collections. So doing it with NSPredicate is as simple as this:

[NSPredicate predicateWithFormat:@"NSApplicationBundleIdentifier=%@",
                                 someIdentifier]];
NSArray* apps = [[[NSWorkspace sharedWorkspace] launchedApplications] 
                          filteredArrayUsingPredicate:predicate];
if ([apps count]==1) {
     // do something
}

The real benefit comes of course when your query is more complex. So beside using while or for to filter a collection just take a look at NSPredicate. It can make things a bit easier. Note: Tiger only :-)

First Responder: A Dynamic Heaven

Sunday, October 22nd, 2006

I grew up with programming languages like Pascal, C, C++ and later Java. All of these languages have a rather static type system. The compiler of these languages can do a lot of good things. It checks for example if you try to use functions that are not valid in a particular context.

These kind of static programming is good for a number of cases and perhaps it’s the best environment for many mission critical systems. At least every bug that is being found by the compiler must not be found by QA.

But this life belt comes at a cost.

(more…)

Cocoa Directory Services Wrapper

Sunday, October 15th, 2006

Dirservices Sample

Mac OS X uses the Directory Service for user authentication and more. The service can be configured to communicate with an Active Directory installation or a LDAP installation to get user information.

There is also a framework to get access to the functionality of this service. So far so good. Unfortunately this framework is a very very very low level framework and for whatever reason it has some very strange naming conventions for functions and data structures.

Searchlight authenticates a user through a Ruby on Rails application to give the user the correct Spotlight results. So I needed the help of Directory Services which cost me a lot of time.

That’s one of the problems when you have to deal with a not so hype framework. It does not have as much documentation, sample code, tutorials like those cool image, animation, … stuff.

(more…)