# Archive for March 2014

## Categories for @protocols

Yup. Categories for protocols. You heard that right. It started with me asking about it on twitter:

This question caused much confusion. "How is that even possible?" "Categories are used to extend existing classes, surely how can you extend a protocol?"

## categories-for-@protocols (2)

And a follow-up post for this one. Already!

I forgot about it, but @pjaspers reminded me that we actually did something similar to this using "regular" language constructs.

What you could do:

1. extend the protocol with the method you need (as has been suggested before)
2. implement the protocol extension method a seperate .m file (similarly named to the .h file the protocol is defined in, I guess). Forgo the @implementation/@end dance, just put the method code "naked" into the file.
3. for each class conforming to the protocol do a #include "Protocol+Implementation.m" in the class' implementation file. You read that right: thats an include and not an import.

## Followup

I was listening to the most recent Debug episode, the one featuring the ever apologetic @caseyliss talking about C#. It's another great episode (but most of the Debug episodes are great - I love the interaction of @gte with his guests). I was particularly interested in this one since I have a similar background: I spent most of my working days on a Microsoft platform and produced a bucketload of C# code (ever since it came out early 2000). Since late 2010 I've been mostly dabbling in Objective-C on the iOS platform. So I was quite curious on what Casey had to say.

While I'm not going to rehash everything here (go listen to the podcast), I agreed with most of it. I do think he forgot an important feature of generics and c# in general: "compile time breakage".

## Quick Look for UIView

Xcode 5.0 introduced an interesting new feature: Quick Look for variables. Basically, it lets you inspect variables and their contents in a graphical way. This allows for interesting ways of viewing the state of your app.

I've been using the feature quite a bit: it's a great way to inspect images or colors you're using in your app, for example. Works great on attributed strings, too.

Xcode 5.1 improves the feature even further with the addition of debugQuickLookObject. This method allows you to provide quick look content for any of your own classes. A bit like debugDescription but more advanced. I haven't had the time to look further into it.

## Inspiration

I am currently at NSConference 6. For those who haven't heard of NSConference, it's a "community conference for OSX and iOS developers". It's a 3-day conference about developing for OSX/iOS by and for developers. If you're an iOS or Mac developer based in Europe, it's a great way to meet the community and learn new stuff.

The problem with these conferences is inspiration. The talks are usually pretty good, and get you fired up to start doing something. Not necessarily with the knowlegde you learn at the conference, but even with what you've been working on at home (or work). The great thing about NSConference (and in general about the smaller conferences) is that they're mixed technical and non-technical. Not everything is about "how to code this-and-that", but it's also how what other people have learned, passing on their experience onto the attendees. Sometimes the talks are mainly about your own "wetware" (thanks @bmf!), how you deal with building apps and interaction with your customers, clients or colleagues.