Feeds

Behind the scenes with Apple's media browser

Integrated advantage

Build a business case: developing custom apps

Mac Secrets Welcome my second “peek behind the scenes” for Cocoa developers. I enjoyed the responses to the first installment, both for and against, and especially the lively email exchanges, some of which I plan to pick up on in the near future!

For now, though, let me just emphasize a couple of important points.

First, this column is not for novice Cocoa developers. If you're new to Cocoa programming, then you definitely shouldn't be casually exploiting undocumented features of the platform. Instead, go check out some of the great Cocoa tutorials here.

Next, when working with undocumented classes and methods, be sure to bulletproof your code as much as possible. As one of my respondents said: “It's important to have your code fail gracefully if a wanted class/method doesn't exist, rather than... uhh... disgracefully!”

To put this in concrete terms, before calling an undocumented method, use the respondsToSelector: message to see if the method exists. Similarly, when checking for the presence of an undocumented class, use NSClassFromString to get a reference to the wanted class. If the returned reference is nil, then you know the class no longer exists.

You won't find these checks in my sample project because I don't want to obfuscate the basic intent of the code and we all have our own ideas about how error handling should work.

Things get slick

Having got the compulsory caveats out of the way, let's take a look at how to implement the so called "media browser" feature inside your own application. As the name suggests, a media browser is designed to let the end user browse for media - meaning things like photos, movies and audio files - before selecting a wanted item and incorporating it into their document.

Karelia Browser

Browse before selecting your media

At time of writing, a number of open-source media browser implementations exist. For example, type "iMediaBrowser" into Google, and you'll be pointed at various different projects. Heck, you can even buy a commercial implementation. The most popular browser, however, is totally free, includes full source code and it's available here. Once you've downloaded the code and looked through it, you'll see that it's quite a complex beast, using an extensible architecture to handle various different media types.

HP ProLiant Gen8: Integrated lifecycle automation

More from The Register

next story
Secure microkernel that uses maths to be 'bug free' goes open source
Hacker-repelling, drone-protecting code will soon be yours to tweak as you see fit
KDE releases ice-cream coloured Plasma 5 just in time for summer
Melty but refreshing - popular rival to Mint's Cinnamon's still a work in progress
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
Put down that Oracle database patch: It could cost $23,000 per CPU
On-by-default INMEMORY tech a boon for developers ... as long as they can afford it
Another day, another Firefox: Version 31 is upon us ALREADY
Web devs, Mozilla really wants you to like this one
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
prev story

Whitepapers

Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Consolidation: The Foundation for IT Business Transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.
Application security programs and practises
Follow a few strategies and your organization can gain the full benefits of open source and the cloud without compromising the security of your applications.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Securing Web Applications Made Simple and Scalable
Learn how automated security testing can provide a simple and scalable way to protect your web applications.