I want to display SQLite Data base content on UIWebView. For that i have a local HTML file. On Body load in html file calling JavaScript Function. Inside the Java Script how to call Objective-c method. how to get Data from Objective c to Java Srcipt.
<html>
<head>
<!-- a script inline -->
<script language="JavaScript" TYPE="text/javascript">
<!--
function myJsFunc()
{
//here i want to call objective-c methods.
}
// -->
</script>
</head>
<Body Bgcolor=#800000 onload="myJsFunc(); return true;">
</Body>
</html>
Objective-C code ......
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path;
NSBundle *thisBundle = [NSBundle mainBundle];
path = [thisBundle pathForResource:@"Demo" ofType:@"html"];
// make a file: URL out of the path
NSURL *instructionsURL = [NSURL fileURLWithPath:path];
[myWebView loadRequest:[NSURLRequest requestWithURL:instructionsURL]];
[self.view addSubView:myWebView];
}
-(NSArray*)FetchingDataFromDataBase{
// Code for retriving data from SQlite data Base, and return NSArray;
return myArray;
}
Inside the Function myJSFunc(), how can call -(NSArray*)FetchingDataFromDataBase.
languageattribute onscriptelements has been deprecated for more than a decade, you can leave it off now. Thetypeattribute should be in lower case, but frankly, you don't need it unless you're including a script not written in JavaScript (this is one of the areas where the HTML5 spec is just codifying existing practice, rather than dictating something new).