/* Server.m StepTalk scriptable server example */ #import #import #import #import #import #include @interface Server:NSObject - say:(NSString *)string; @end @implementation Server - (STEnvironment *)scriptingEnvironment { /* here we should add some objects or class references ... */ return [STEnvironment defaultScriptingEnvironment]; } - (NSDate *)date { return [NSDate date]; } - say:(NSString *)string { printf("%s\n",[string cString]); return self; } @end int main(int argc, const char **argv) { NSAutoreleasePool *pool; NSConnection *connection; Server *server = [Server new]; pool = [NSAutoreleasePool new]; connection = [NSConnection newRegisteringAtName:@"Server" withRootObject:server]; if (!connection) { NSLog(@"Unable to register server"); [pool release]; return 1; } NSLog(@"Server started"); [[NSRunLoop currentRunLoop] run]; RELEASE(connection); RELEASE(pool); return 0; }