O'Reilly logo

Beginning Mac OS® X Programming by Drew McCormack, Michael Trent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.4. Exercises

  1. odify the script you completed in the fifth Try It Out example ("Finishing Off Slideshow Maker") so that the user is prompted for the duration of each slide. Make sure you handle invalid user input appropriately.

  2. The Piles of Pictures application works fine if the user does not try to do anything unusual, but it doesn't do a good job of taking into account exceptional circumstances. In particular, it doesn't consider the possibility that the user's iPhoto album contains no albums, or that the albums selected by the user are all empty.

    Modify the Piles of Pictures script so that it checks that the user selected at least one album, and that the selected albums are not all empty. If either of these circumstances arises, throw an error, and catch it again in the clicked handler. Display an alert panel if an error occurs. (Hint: Read about the alert panel class in the AppleScriptKit dictionary.)

  3. Piles of Pictures allows you to vary the scaling of the photos drawn in the poster, but the same scaling factor applies to all photos. The purpose of this exercise is to allow the user to randomly vary the scaling from one photo to the next, so that the poster ends up with a distribution of different sizes.

    Add a second slider to the Piles of Pictures user interface to allow the user to choose a variation factor from 0.0 to 1.0. Choose a random value for each photo from the range stipulated by the variation factor, and add it to the original scaling factor such that the photos each ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required