Online Book Reader

Home Category

AppleScript_ The Definitive Guide - Matt Neuburg [248]

By Root 1621 0

description="Verify if an object exists.">

type="specifier"/>

description="The class of the new object." type="type">

Next comes the Pairs Suite. The application's name, frontmost, and version properties were generated automatically; the application's person element, and the person class itself, were added by you. The material you've actually had to create is shown here in bold type:

description="The name of the application." type="text" access="r"/>

description="The version of the application." type="text" access="r"/>

description="The person's name." type="text">

Even though only a dozen lines were added by you, there's lots of room to go wrong here. (I speak from experience.) The following points are worth emphasizing:

You must make up some four-letter codes.

The codes 'pAIR' and 'pRSN' are arbitrary. It is crucial, however, that they not overlap with existing four-letter codes. One way to feel confident of this is to use some capital letters, as we've done here; Apple reserves to itself all four-letter codes consisting entirely of lowercase letters.

You must use existing four-letter codes.

The name property of the person class has code 'pnam'. This is a standard property, already defined in AppleScript, and it is essential to get the code right.

You must match Cocoa keys with your code.

The Cocoa key for the person element of the application class is "persons"; that's because persons is the name of the instance variable in MyObject through which the collection of Person objects is accessed. The Cocoa key for the person class is "Person"; that's because Person is the name of the Cocoa class implementing this AppleScript class. The Cocoa key for the person class's name property is "name"; that's because name is the name of the instance variable in Person representing the name property. A mistake here—even a discrepancy in capitalization between the Objective-C

Return Main Page Previous Page Next Page

®Online Book Reader