我想SQLite
在 UIWebView 上显示数据库内容。为此,我有一个本地 HTML 文件。在调用 JavaScript 函数的 html 文件中加载正文。Java Script里面如何调用Objective-c方法。如何从 Objective c 获取数据到 Java 脚本。
<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 代码......
- (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;
}
在Function myJSFunc
()里面,怎么能调用-(NSArray*)FetchingDataFromDataBase.