Software Developer and Coffee Sink.

The university project CUE3 & CueTable created a virtual cooperated media space.

A pattern to switch on value of an object

One control structure of C and many other languages is the switch-statement, that allows to perform different code-blocks depending of a certain variable

switch (n) {
  case 0:
      //execude code for case n == 0
    break;
  
  case 1:
      //execude code for case == 1
   break;

  default:
    printf("whatever");
}

where n needs to be an int or a char (that is actually an int, too) and enums of those types.

But we live in a objectified world today. If it comes to flow-control depending on objects, switch is useless. We need to use if-statement, that can be quite hairy easily.
One could argue, that ...

Variadic Lists and Blocks

Matt Gallagher posted an great article about veridic lists. In his conclusion he writes

In your own code, variadic methods should be used sparingly — passing variables in an NSArray or NSDictionary is safer (if slightly slower and syntactically more verbose) due to the fact that these classes do offer introspection.

And I think he is right.
But now I found a situation, where it makes much more sense to have a veridic list of arguments rather a NSArray or NSDictionary.

I wrote a Category method on NSArray, that allows the user, to filter the array by blocks and create a ...

Beat This, Python!

I love Python. I love Objective-C.

"Huh?!" I hear you thinking, "they are complete different, how can you like both"?

Well, nothing is perfect, even in a lovely relationship.
There are things, that drive me crazy in one — and things that are missing, form my point of view, in the other language

One thing I'd love to see in Python, that Objective-C has, is extending a class — Categories.
Every language should have functional tools like pythons List Comprehensions, but Objective-C hasn't.

But since Apple extended Objective-C by introducing Blocks to the underlaying C, it is now possible to ...