Behind the scenes with Apple's media browser

Integrated advantage


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.

Similar topics


Other stories you might like

  • Monero-mining botnet targets Windows, Linux web servers
    Sysrv-K malware infects unpatched tin, Microsoft warns

    The latest variant of the Sysrv botnet malware is menacing Windows and Linux systems with an expanded list of vulnerabilities to exploit, according to Microsoft.

    The strain, which Microsoft's Security Intelligence team calls Sysrv-K, scans the internet for web servers that have security holes, such as path traversal, remote file disclosure, and arbitrary file download bugs, that can be exploited to infect the machines.

    The vulnerabilities, all of which have patches available, include flaws in WordPress plugins such as the recently uncovered remote code execution hole in the Spring Cloud Gateway software tracked as CVE-2022-22947 that Uncle Sam's CISA warned of this week.

    Continue reading
  • Red Hat Kubernetes security report finds people are the problem
    Puny human brains baffled by K8s complexity, leading to blunder fears

    Kubernetes, despite being widely regarded as an important technology by IT leaders, continues to pose problems for those deploying it. And the problem, apparently, is us.

    The open source container orchestration software, being used or evaluated by 96 per cent of organizations surveyed [PDF] last year by the Cloud Native Computing Foundation, has a reputation for complexity.

    Witness the sarcasm: "Kubernetes is so easy to use that a company devoted solely to troubleshooting issues with it has raised $67 million," quipped Corey Quinn, chief cloud economist at IT consultancy The Duckbill Group, in a Twitter post on Monday referencing investment in a startup called Komodor. And the consequences of the software's complication can be seen in the difficulties reported by those using it.

    Continue reading
  • Infosys skips government meeting – and collecting government taxes
    Tax portal wobbles, again

    Services giant Infosys has had a difficult week, with one of its flagship projects wobbling and India's government continuing to pressure it over labor practices.

    The wobbly projext is India's portal for filing Goods and Services Tax returns. According to India's Central Board of Indirect Taxes and Customs (CBIC), the IT services giant reported a "technical glitch" that meant auto-populated forms weren't ready for taxpayers. The company was directed to fix it and CBIC was faced with extending due dates for tax payments.

    Continue reading
  • Google keeps legacy G Suite alive and free for personal use
    Phew!

    Google has quietly dropped its demand that users of its free G Suite legacy edition cough up to continue enjoying custom email domains and cloudy productivity tools.

    This story starts in 2006 with the launch of “Google Apps for Your Domain”, a bundle of services that included email, a calendar, Google Talk, and a website building tool. Beta users were offered the service at no cost, complete with the ability to use a custom domain if users let Google handle their MX record.

    The service evolved over the years and added more services, and in 2020 Google rebranded its online productivity offering as “Workspace”. Beta users got most of the updated offerings at no cost.

    Continue reading
  • GNU Compiler Collection adds support for China's LoongArch CPU family
    MIPS...ish is on the march in the Middle Kingdom

    Version 12.1 of the GNU Compiler Collection (GCC) was released this month, and among its many changes is support for China's LoongArch processor architecture.

    The announcement of the release is here; the LoongArch port was accepted as recently as March.

    China's Academy of Sciences developed a family of MIPS-compatible microprocessors in the early 2000s. In 2010 the tech was spun out into a company callled Loongson Technology which today markets silicon under the brand "Godson". The company bills itself as working to develop technology that secures China and underpins its ability to innovate, a reflection of Beijing's believe that home-grown CPU architectures are critical to the nation's future.

    Continue reading

Biting the hand that feeds IT © 1998–2022