Feeds

Behind the scenes with Apple's media browser

Integrated advantage

Maximizing your infrastructure through virtualization

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.

Seven Steps to Software Security

More from The Register

next story
Whoah! How many Google Play apps want to read your texts?
Google's app permissions far too lax – security firm survey
Chrome browser has been DRAINING PC batteries for YEARS
Google is only now fixing ancient, energy-sapping bug
Do YOU work at Microsoft? Um. Are you SURE about that?
Nokia and marketing types first to get the bullet, says report
Microsoft takes on Chromebook with low-cost Windows laptops
Redmond's chief salesman: We're taking 'hard' decisions
EU dons gloves, pokes Google's deals with Android mobe makers
El Reg cops a squint at investigatory letters
Big Blue Apple: IBM to sell iPads, iPhones to enterprises
iOS/2 gear loaded with apps for big biz ... uh oh BlackBerry
OpenWRT gets native IPv6 slurping in major refresh
Also faster init and a new packages system
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
prev story

Whitepapers

Top three mobile application threats
Prevent sensitive data leakage over insecure channels or stolen mobile devices.
The Essential Guide to IT Transformation
ServiceNow discusses three IT transformations that can help CIO's automate IT services to transform IT and the enterprise.
Mobile application security vulnerability report
The alarming realities regarding the sheer number of applications vulnerable to attack, and the most common and easily addressable vulnerability errors.
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.
Consolidation: the foundation for IT and business transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.