I want to display the SQLitecontents of a database in a UIWebView. For this, I have a local HTML file. Loading the body in an html file that calls the JavaScript function. Inside Java Script, how to call the Objective-c method. how to get data from Objective-c in Java Srcipt.
<html>
<head>
<script language="JavaScript" TYPE="text/javascript">
</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"];
NSURL *instructionsURL = [NSURL fileURLWithPath:path];
[myWebView loadRequest:[NSURLRequest requestWithURL:instructionsURL]];
[self.view addSubView:myWebView];
}
-(NSArray*)FetchingDataFromDataBase{
return myArray;
}
Inside the function myJSFunc(), you can call-(NSArray*)FetchingDataFromDataBase.
source
share