SQLite
UIWebViewにデータベースコンテンツを表示したい。そのために私はローカルHTMLファイルを持っています。JavaScript関数を呼び出すhtmlファイルのボディロードについて。Javaスクリプト内でObjective-cメソッドを呼び出す方法。ObjectivecからJavaSrciptにデータを取得する方法。
<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;
}
関数myJSFunc
()内で、どのように呼び出すことができますか-(NSArray*)FetchingDataFromDataBase.