Programming Pitfalls to Avoid
This section describes some things to look out for as you debug your application.
WebScript Programming Pitfalls
Because WebScript looks so much like Objective-C and C, it's easy to forget that WebScript isn't either of these languages. When you're debugging WebScript code, watch out for the following tricky spots:
- WebScript supports only objects that inherit from NSObject. As most objects inherit from NSObject, this limitation is easy to overlook. Notably, EOFault does not inherit from NSObject, so you cannot use it in WebScript code.
- The == operator is supported only for NSNumber objects. If you use == to compare two objects of any other class, the operator compares the addresses of the two objects, not the values of the two objects. To test the equality of two objects, use the isEqual: method.
NSString *string1, *string2;
// WRONG! if (aString1 == aString2) ...
// Right if ([aString1 isEqual:string2]) ...
i = 0; if (i++ < 1 ) // This code never gets executed.
// WRONG! produces a divide by 0 if a is 0. if ((a == 0) || (b / a) > 5) ...For more information, see the chapter "The WebScript Language".
Table of Contents Next Section