Table of Contents
Previous Section
To access a scripted object's methods from compiled code, you simply get the object that implements the method and send it a message:
// Get the object id mainPage = [WOApp pageWithName:@"Main"]; // Send it a message [mainPage setMessage:@"You have won a trip to Hawaii!!"];
To avoid compiler warnings, you should declare the scripted method you want to invoke in your code. This is because scripted objects don't declare methods---their methods are parsed from the script at run time. If you don't declare their methods in your code, the compiler issues a warning that the methods aren't part of the receiver's interface.
For example, suppose you have a component called Main that includes the method setMessage: (this could be an implicit variable accessor method or an explicitly implemented method in your script). To access this method from your compiled code, you'd have to include a declaration such as the following in your code's implementation file:
While it's certainly straightforward to access a scripted object's methods from compiled code, you may not want to have that degree of interdependence between your scripts and your compiled code. In the Registration application, Person's validate method could have directly set the value of the message variable in Main.wos. Instead, validate puts its results into an NSDictionary that it then returns. Likewise, you may want to minimize the interdependencies between your scripts and your compiled code to facilitate reusability.
@interface Dummy:WOComponentController
- (void)setMessage:(NSString *)aMessage;
@end