macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Modding Apple Sample Code
Pages: 1, 2, 3, 4

Download the Sample Code

You'll find a copy of the MovieVideoChart sample code at the Apple Developer site. Download your copy using either zip or dmg format, and decompress or mount the archive to access the actual files. You'll discover that Apple has included a compiled, ready-to-use version at the top level of both archives.



Survey the Software

Unsurprisingly, before you start modding sample code, you've got to figure out which bits you want to keep and which you want to toss. Run the application and open a movie or two. (To open a QuickTime movie to test the software, select File → Open.) Play with the software and try to determine the core functionality you want to extract and build on. In this case the goal is already stated: to create a proper frame-by-frame, ordered display of (unencrypted) QuickTime movies.

Develop a To-Do Checklist

Here are the things that stand out about MovieVideoChart in its current state and what needs to be changed to get it to the goal. These are typical of the kinds of critiques you'll want to apply to any sample app. Try to enumerate your desired changes with as much detail as possible while keeping your changes realistic and achievable.

  • The pictures are quite small. They need to be larger and easier to view.
  • The only pictures of interest are the media (decode-ordered) pictures. Eliminate the others and promote the decode-ordered frames to the top of the window.
  • The default value for the frame display slider (initially in the lower-left of the window) is half width. It should be full width by default, and moved to a more appropriate part of the window.
  • A lot of text will become unnecessary and should be hidden or removed. Once the text is dealt with, the resulting white space should be used by the main display area.
  • Much of the interframe indicators, like the dots and the edits and the diagonal lines, are not of interest and can be tossed.
  • The Use Seconds/Use Time Scales pop-up is not relevant to the goal application. Disable and hide this pop-up.

Prepare a Backup and a Modification Log

Once you've established your modification list, you'll want to back up the original, unmodified application. Copy the entire sample folder with all the source code and other material provided by Apple. Keep this original copy on hand as a reference for changes and a source for reversion if necessary.

Next, create a modification log, either on paper or in your favorite text editor. As much as you might like the progress of sample code modification to be forward, it's often depressingly back and forth as you test out new mods and then have to revert them until you find the right balance of change and stability. Prepare to take copious notes as you test. Modding apps is more an exercise of exploration than of original design.

Tip: You can "undo" past previous saves in Xcode if you don't quit out of the program. When you're prompted to confirm that you want to undo past a save point, just let the program know that it's okay.

Read Through the Source Code

Most Apple sample app packages are small. Because they're meant to demonstrate a single technology, there's not a lot of excess code that you'll have to slog through. This means that you can scan through the source code fairly quickly to get at least a gist of the items you'll want to work with and change. In the case of MovieVideoChart, pretty much all the changes you'd want to make are limited to ChartView.c (Figure 2). You wouldn't know this, however, until you read through the code and discovered where the meat of the program was located.

Figure 2

Figure 2: Apple sample apps are usually sparse and easy to follow. The only two files of interest here are ChartWindow.c and ChartView.c. As a rule, you can basically ignore main.c, at least as far as application semantics are concerned.

Pages: 1, 2, 3, 4

Next Pagearrow