Here are some of the more subtle differences between WebScript and Objective-C:
// NO!! This won't work.NSRange is a structure. string = [NSString substringWithRange:aRange];
// This is fine. [self logWithFormat:@"The value is %@", myVar]; // NO!! This won't work. It prints the address of var1. [self logWithFormat:@"The values are %d and %s", var1, var2];
For example, suppose you want to compare two numeric values using the enumerated type NSComparisonResult. This is how you might do it in Objective-C:
result = [num1 compare:num2]; if(result == NSOrderedAscending) /* This won't work in WebScript */ /* num1 is less than num2 */
But this won't work in WebScript. Instead, you have to use the integer value of NSOrderedAscending, as follows:
result = [num1 compare:num2]; if(result == -1) /* num1 is less than num2 */
For a listing of the integer values of enumerated types, see the "Types and Constants" section in the Foundation Framework Reference.
Table of Contents Next Section