Apple WebObjects 3.5 Manuel d'utilisateur Page 175

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 218
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 174
WebScript Language Elements
175
Explicitly specifying a class in a variable or method declaration is called
static typing.
Because variables and return values are always objects, the only supported
data types are classes. You can specify any class that your application
recognizes when you statically type a variable or a method. For example,
each component in your application is a class, so you can do this:
CarPage *carPage = [[self application] pageWithName:"CarPage"];
Also, the default application executable used to run your application
contains the definitions of classes from the Foundation, WebObjects, and
Enterprise Objects frameworks, so these declarations are valid:
NSString *myString; //Foundation classes
WOContext *theContext; //WebObjects classes
EOEditingContext *editingContext; //Enterprise Objects classes
Plus, if you’re writing a component that uses database access, your
application has an EOModel file that translates tables in your database into
objects. You can specify any entity named in that model file as a class. For
example:
Movies *moviesEntity; //entities from your eomodel
Static typing is supported so that WebObjects Builder can correctly parse
your script file and help you decide which variables you can correctly bind
to certain dynamic elements. (For more information on this, see the online
book WebObjects Tools and Techniques.) As far as WebScript is concerned, all
variables are of type
id.
Note: WebObjects performs absolutely no type checking. The following is
valid WebScript:
NSNumber *aNumber = @"Wait! I’m a string, not a number!";
NSString *aString = 1 + 2;
Statements and Operators
WebScript supports most of the same statements and operators that C
supports, and they work in much the same way. This section describes only
the differences between statements and operators in C and statements and
operators in WebScript.
Vue de la page 174
1 2 ... 170 171 172 173 174 175 176 177 178 179 180 ... 217 218

Commentaires sur ces manuels

Pas de commentaire