Feeds

Fun with CoreGraphics, Part II

Split personality framework

Boost IT visibility and business value

Cross-application notifications

Different applications can register for the same notifications (e.g., loginwindow and Activity Monitor are both interested in when new processes start running or existing processes die), and you can even register for the same notification more than once from different classes within the same program. In this specific case, though, you really would have to make use of the userData parameter to determine which object is interested in the notification - if you see what I mean.

To unregister a notification procedure (typically you’d do this in your object’s dealloc method), use the CGSRemoveNotifyProc call. This routine has the exact same function prototype as CGSRegisterNotifyProc - just pass the same three parameters.

The notification procedure type looks like this:

typedef void (* CGSNotifyProcPtr)(CGSNotificationType type, void * data, NSUInteger dataLength, void *userData);

In other words, the first parameter is the notification type, corresponding to the second parameter to CGSRegisterNotifyProc. The last parameter, userData, will be whatever you passed as the third parameter to CGSRegisterNotifyProc.

You’ll probably want to use the same notification procedure for several different notifications, in which case you can check the first parameter to see what notification you’re dealing with. Obviously, if you’ve only registered one notification for each notification procedure, the check is superfluous.

The "meat" of the notification is in the data and dataLength parameters. The significance of these parameters varies depending upon the notification type that’s being received. More on that next time. The bad news is that I’ve said so much, I’m out of space. There’s no sample project this time, but next month I’ll provide source for an app which receives CoreGraphics notifications, and I’ll delineate some of the notification types available. I’ll also wrap up this mini-series on CoreGraphics by pointing you to some of the other goodies contained therein. ®

The essential guide to IT transformation

More from The Register

next story
Munich considers dumping Linux for ... GULP ... Windows!
Give a penguinista a hug, the Outlook's not good for open source's poster child
The Return of BSOD: Does ANYONE trust Microsoft patches?
Sysadmins, you're either fighting fires or seen as incompetents now
Intel's Raspberry Pi rival Galileo can now run Windows
Behold the Internet of Things. Wintel Things
Microsoft cries UNINSTALL in the wake of Blue Screens of Death™
Cache crash causes contained choloric calamity
Eat up Martha! Microsoft slings handwriting recog into OneNote on Android
Freehand input on non-Windows kit for the first time
Time to move away from Windows 7 ... whoa, whoa, who said anything about Windows 8?
Start migrating now to avoid another XPocalypse – Gartner
You'll find Yoda at the back of every IT conference
The piss always taking is he. Bastard the.
prev story

Whitepapers

5 things you didn’t know about cloud backup
IT departments are embracing cloud backup, but there’s a lot you need to know before choosing a service provider. Learn all the critical things you need to know.
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.
Build a business case: developing custom apps
Learn how to maximize the value of custom applications by accelerating and simplifying their development.
Rethinking backup and recovery in the modern data center
Combining intelligence, operational analytics, and automation to enable efficient, data-driven IT organizations using the HP ABR approach.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.