I finally figured it out! Here's the relevant JavaScript code:
Code:
function checkAnswers() {
// Do stuff to see if all answers were correct
...
// Send all correct status back to Objective-C
window.location = "/allCorrect/" + allCorrect;
}
Here's the relevant Objective-C code:
Code:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ( [request.mainDocumentURL.relativePath isEqualToString:@"/allCorrect/false"] ) {
NSLog( @"Nope, that is not right!" );
return false;
}
if ( [request.mainDocumentURL.relativePath isEqualToString:@"/allCorrect/true"] ) {
NSLog( @"You got them all!" );
return false;
}
return true;
}
I also just posted this as a tutorial on my blog:
iPhone/Web 2.0 » Send a BOOL value from JavaScript to Objective-C.