Archive for the ‘Cocoa Libraries’ Category

Objective-C and C#: Brothers From Another Mother

05/24/2012 Leave a comment

My colleague Paul Irwin just posted an article called Translating Objective-C to C# – Part 1 of n. I think it’s an excellent synopsis. Having myself spent nearly a year and a half doing Objective-C programming part time before learning to C#, this is a topic that hits home for me. There are a couple of areas that warrant some additional clarification, as they are obscure for most Objective-C and .NET programmers alike.
Read more…

Part II: Spawning Threads Using Selectors With Multiple Parameters

05/18/2010 9 comments

In Part I, we introduced a method that emulates the Apple-supplied convenience method performSelectorInBackground:withObject:, but which adds support for selectors that take multiple objects as arguments. We saw the power of NSInvocation objects, but also saw how they were a bit cumbersome to use on a routine basis. Our solution gave us what we wanted by allowing us to pass in an array of objects to be used, along with a multi-parameter selector, to invoke an arbitrary method on a background thread (or on the main thread).

This solution is a great step forward when we need to invoke something like [myObj setCharacter:@"The Doctor" currentActor:@"Matt Smith"]. But what if we have a bunch of methods that don’t take objects? Wrapping them all in NSValues begins to really litter-up the code, and is frankly a bit tedious. And what if one want to invoke something like [myObj setCharacter:@"The Doctor" favoriteActors:@"Tom Baker", @"David Tennant", @"Matt Smith"]? There has to be a cleaner way, right? Behold! There is, and the answer lies in the somewhat obscure-ish va_arg macro. Now we can save the world from our unwieldy code. Allons-y!

Read more…

The Names of Fonts Available on iPhone OS

03/24/2010 2 comments

Interface Builder is great. It’s an Apple-y app the lets you build your own Apple-y apps. It’s all so much Apple-y goodness. Well, maybe even too much goodness. Say you want to change the font family for your UILabel. Maybe you like the Helvetica. Or maybe you like the Arial.  So off you go to the Attributes Inspector and dutifully click on the Font attribute.  POP!  The familiar ol’ standard OS X font selection dialog window springs up in front of you…with all your workstation’s installed and active fonts.  Here’s the catch: the vast majority of those fonts will not be available on your iPhone or iPod Touch application. What a downer. But we can at least sort this out easily enough. Read more…