28 #import "NE10DemoViewController.h" 29 #import "test_funcs.h" 33 - (void)runNe10TestThreadMain;
42 self->lock = [[NSLock alloc] init];
43 self->ne10Finished = TRUE;
44 self->ne10Result = NULL;
46 self.webView.delegate =
self;
47 NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"html" inDirectory:nil];
48 NSURL *url = [NSURL fileURLWithPath:htmlFile];
49 NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
51 [
self.webView loadRequest:requestObj];
54 - (void)didReceiveMemoryWarning
56 [
super didReceiveMemoryWarning];
61 - (BOOL)webView:(UIWebView *)webView
62 shouldStartLoadWithRequest:(NSURLRequest *)request
63 navigationType:(UIWebViewNavigationType)navigationType {
64 NSURL *url = request.URL;
65 if ([[url scheme] isEqualToString:
@"ne10"]) {
66 if (self->ne10Finished) {
68 if (self->ne10Result != NULL && ![self->ne10Result isEqual:
@"\"(null)\
""]) {
69 NSString *jsFunction = [NSString stringWithFormat:@"returnFromObjectivec(%@)", self->ne10Result];
70 [
self.webView stringByEvaluatingJavaScriptFromString:jsFunction];
72 self->ne10Finished = FALSE;
73 NSThread* ne10TestThread = [[NSThread alloc] initWithTarget:self
74 selector:@selector(runNe10TestThreadMain)
76 [ne10TestThread start];
84 - (void)runNe10TestThreadMain {
86 self->ne10Result = [NSString stringWithFormat:@"%s", NE10RunTest()];
88 self->ne10Result = [
self->ne10Result stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
89 self->ne10Result = [NSString stringWithFormat:@"\"%@\"",self->ne10Result];
90 self->ne10Finished = TRUE;