Leopard Developer Application Technologies Overview

Mac OS X Leopard is an operating system designed for innovation. It comes packed with rich application technologies that make it easier for you to create compelling, rich, and amazing new applications. Applications that go far beyond the ordinary and which can truly captivate users. Some of these application technologies, such as Time Machine, iChat Theater and Calendar Store, let you fully integrate with Leopard and provide your users with the best possible experience. Others, such as Core Animation and 64-bit support, give you strong foundations on which to build your application.

This article, the third installment in the Leopard Technology Series for Developers, provides an overview of Leopard's application technologies. First, let's take a look at some new technologies that you can use to integrate your applications with the overall Leopard platform experience.

Integrating Your Application With Leopard

Leopard comes with a wide range of technologies that directly benefit users. Time Machine keeps their data safe and secure. The Calendar Store lets any application display, create, and edit iCal data. And, iChat adds the ability to share a view of a user's application with other users across the Internet. By integrating with these technologies, your applications will become more useful, desirable, and essential to your users.

Working Effectively with Time Machine

Time machine is a comprehensive backup solution for the system. It automatically makes a complete backup of all the files on the system to either locally attached external hard drives or remote network server file systems. As a user makes changes—creating, updating, or deleting files—Time Machine backs up those changes as well, creating a history of the file system that can be navigated by date. It's a major advance for the majority of users who know that they should regularly back up their data, but don't. Now, data back up and recovery is effortless.

Figure 1: Time Machine gives users the ability to work with their files as they change over time.

Time Machine lets users work with their files as they change over time.

Since Time Machine works hand-in-hand with the file system, and keeps track of files as they change over time, there are a few guidelines you should follow about writing files to the disk. The first is to make sure that temporary files and easily recreated caches and indexes aren't backed up by Time Machine. There are a few locations already provided for this kind of data that you should use whenever possible:

These locations are automatically excluded from Time Machine's backup processing. If your application writes data that shouldn't be backed up to a location that isn't automatically excluded by Time Machine, you can flag files as excluded using a single function call. For example, in a Cocoa application, you could use the following to exclude a file:

NSURL *url = [NSURL fileURLWithPath:@"/path/to/file"];
CSBackupSetItemExcluded((CFURLRef)url, true, false);

The second guideline you should follow is to avoid putting small amounts of volatile data into otherwise large and static files. If you have data files that are updated frequently to change a small percentage of the data in that file, Time Machine will copy the entire file, taking up more space on the backup disk. If, instead, you can separate the volatile data into a smaller separate file, Time Machine will be able to back up changes to the smaller file and make more efficient use of backup disk space.

The third guideline is that you should provide a Quick Look preview for any data types that your application writes which aren't already handled by a system-level Quick Look plug-in. QuickLook allows the system to preview documents without opening an application. They are available in Spotlight searches and in the Finder, as well as in Time Machine.

Integrating with iChat

Ichattheater20060807

Mac users love to exchange quick messages, have video conferences, and collaborate on each other's desktops across the network. You used to need a separate application for each of these tasks. With iChat for Leopard, it's all built right in. And, with iChat Theater, you can display content from any Instant Message-enabled application as part of a video conference session.

Integration with iChat Theater is straightforward. Once your application registers with the Instant Message framework and starts a session, it receives a series of Core Video callbacks in which you can return frames of image data. Audio data can be shared as well via a Core Audio-based API.

The Instant Message framework also exposes an API for accessing the presence data of the local user as well as that of remote users connected to an instant messaging service. You can obtain usernames, icons, and status messages easily using this feature. For example, your application could use this feature to show which users are online and share data with them via iChat Theater.

Using the Calendar Store

Calendar Store

iCal has long shared data with phones, PDAs, and iPods, as well as with other computers through .Mac. By serving as a central store for calendars and to-dos, it has become an essential part of many users' daily life. Now, in Leopard, your application can easily interoperate with this data via the new Calendar Store framework. This framework handles all of the details of maintaining the data, including recurring events and time zones, and presents a simple and straightforward API for working with that data.

For example, to get a list of all the events in the Calendar Store that occur in a particular date range, you could use the following code:

CalCalendarStore *store = 
    [CalCalendarStore defaultCalendarStore];

NSPredicate *predicate = [NSPredicate 
    eventPredicateWithStartDate:startDate
                        endDate:endDate 
                      calendars:[store calendars]];
                      
NSArray *events = [store eventsWithPredicate:predicate];

Once fetched, calendars, events, and tasks may be changed or deleted. Your application can also receive notifications indicating updates to these objects, allowing it to seamlessly react when an event is updated in iCal or in another application.

Building Better Applications Using Leopard Technologies

Beyond the technologies in Leopard that let your application integrate well with the system and provide the best possible user experience, Leopard comes with several new application technologies that let you build applications that are fundamentally different from those you've been able to build before. You can also build them faster than ever.

Picking Up the Pace of Cocoa Application Development

Cocoa is, quite simply, the best tool to use to create compelling modern Mac OS X applications. Thanks to Interface Builder and the richness of the Application Kit and Foundation frameworks, many tasks that take hundreds or thousands of lines of code in other environments are taken care of in a line or two. The lingua franca of Cocoa is the highly dynamic Objective-C. In Leopard, Objective-C has been modernized with garbage collection, fast iteration, and powerful declared property accessors. These features will help increase your productivity when you work with the language.

To open up the benefits of the Cocoa frameworks to a wider developer audience, Leopard embraces two other highly dynamic languages for use in building Cocoa applications: Ruby and Python. These two languages are an excellent fit for integrating with the Cocoa frameworks, and they both have high quality bridges to Objective-C. These bridges allow you to mix and match Objective-C, Ruby, and Python, allowing you to choose the best tool for the job at hand while using high level Cocoa features such as Key-Value Coding (KVC) and Key-Value Observing (KVO).

Users have long had the ability to build new solutions that combine the features from other scriptable applications. In Leopard, Cocoa developers get a powerful new tool, the Scripting Bridge, to do this programmatically. The Scripting Bridge allows you to automatically build "glue" code to access a scriptable application with standard Objective-C method calls. For example, using the Bridge, you could get the name of the current iTunes track with the following line of code:

NSString *currentTrackName = [[iTunes currentTrack] name];

The Scripting Bridge uses native Cocoa data types, such as NSString and NSArray, requires far less code than using an NSAppleEventDescriptor, and runs more than twice as fast as a precompiled NSAppleScript.

Effortlessly Animating User Interfaces

Icon Coreanimation

One of the most intriguing components in Leopard is Core Animation, a powerful new technology that lets you create groundbreaking user experiences and data visualizations by animating layers of graphics, text, and video. With Core Animation you can use common motion graphics techniques, such as keyframes, moves, and transitions, to animate your application's visual content or user interface elements.  Core Animation is integrated with Core Image, Core Video and Quartz composer and takes advantage of GPU acceleration. Core Animation provides a unifying model for seamlessly accessing these graphics technologies and allows you to use them to create a wide range of visualizations and user experiences.

The Core Animation framework is easy to use, yet also highly efficient. Animations, once set into motion, are controlled by a separate thread independent of your application's main run loop. As a result, your application is free to process further events even as an animation is running. If an animation's properties are changed while it is in flight, the Core Animation framework automatically retargets the animation appropriately and seamlessly. Your application simply tells the framework what to do, and Core Animation takes care of the low-level details driving the animation.

In addition to powerful lower-level Core Animation APIs, Cocoa in Leopard builds on the abilities of Core Animation by integrating it seamlessly into the NSView hierarchy model. This integration allows you to quickly and easily integrate animations into your application using Interface Builder or by calling methods on views in your code. For example, you could replace the following:

[myView setFrame:rect];

You can now make the view animate to a new location by using the following code:

[[myView animator] setFrame:rect];

This comprehensive level of integration of Core Animation into Cocoa means that it is easy and straightforward to add impressive animations to your application with a minimum of extra code. And these animations can provide the polish and responsiveness needed to revolutionize your application's user interface.

Taking Full Advantage of Modern Hardware

Icon 64bit

The latest Mac systems are incredibly powerful. They feature the latest in CPU technology and, in the case of the latest Mac Pros and Xserves, can be configured with far more than 4GB of memory. These Macs run current 32-bit Mac OS X applications faster than ever, but their capabilities, especially their ability to address large amounts of memory, can't be fully utilized by those applications. When an application's needs exceed the ability of a 32-bit memory space, it's time to change it so that it can run as a 64-bit application.  Leopard brings complete 64-bit support to all of the Mac OS X frameworks, allowing you to create Carbon and Cocoa applications that can take full advantage of the latest hardware now and well into the future.

Not only does 64-bit support let your application address all of the memory in a Mac Pro or an Xserve, it may let you take advantage of CPU characteristics that could further increase the performance of your application. For example, there may be performance benefits for CPU-bound code thanks to the increased number of registers available to 64-bit applications on Intel-based systems. And, the ability to load datasets in excess of 4GB will open up the potential for entirely new classes of applications—many of which couldn't have even been imagined in a 32-bit world.

Most applications won't need to make the jump to 64-bit yet. However, there's no reason not to be ready to move an application to 64-bit in the future. To ensure that you are ready, you'll want to be sure that you write your code in a manner that's  easier to move to a 64-bit later future. The best way to do this is to move away from deprecated APIs, such as QuickDraw, and adopt the use of the new NSInteger and NSUInteger data types that are used throughout the system frameworks in Leopard in place of int and unsigned int. By doing these tasks now, you'll have much less work to do later.

Get Started with Leopard

The next generation of the world's most advanced operating system is now available. Tap into the innovative technologies of Mac OS X Leopard and design your products with new and compelling features. With an ADC Premier or Select Membership, you have a range of developer resources from Apple engineers and experts, including ADC on iTunes, Coding Headstarts, the ADC Compatibility Labs and more. Learn how ADC Memberships provide you Apple expertise. From code to market.

Updated: 2007-10-26

 
 
 

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2009 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice