I am learning to write an iOS-native webkit app. In Xcode 3.x, I have index.html distributed in Resources folder and the following code works correctly:
- (void)viewDidUnload
{
[super viewDidUnload];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData)
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:path];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}
}
The index.html is not loaded when I create a project on Xcode 4.2. I have the index.html in the “Supporting Files” folder. Have I missed something? Please help.
Thanks
Adrian
It was my carelessness. The function should be viewDidLoad, not viewDidUnload.
Thanks.