Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-24-2009, 04:51 AM   #4 (permalink)
chuck
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default

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.
__________________
German Course: Learn German anywhere! Chess Player: Study Chess anywhere!

Last edited by chuck; 04-24-2009 at 06:33 AM. Reason: blog link to tutorial
chuck is offline   Reply With Quote
 

» Advertisements
» Online Users: 450
20 members and 430 guests
apatsufas, CatfishBlues Games, ChrisYates, desbrina, falco1973, gogoman, ipodphone, Lisafleu, LunarMoon, mer10, milanalina, PavelMik, Robemtims, sacha1996, solie, themartist, VinceYuan, Wikiboo, ziocleto, zzeze
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,621
Threads: 94,087
Posts: 402,801
Top Poster: BrianSlick (7,990)
Welcome to our newest member, solie
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:58 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.