Search code examples
iphoneipadsqlitexcode4uiwebview

Getting SQLite data into UIWebView


I'm modifying a SDK tutorial that pulled from a very basic SQLite DB and displayed the data from one field in an UIImageView, and description in an UITextView.

My project requires that the TextView be changed to a WebView.

I'm pretty close, but my hangup is with these two lines of code–I think!

NSString *descData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[animal description]]];
[self.animalView.animalDesciption loadHTMLString:descData baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];

Everything is working good (that is the app doesn't crash), except that nothing is displayed in the description/UIWebView!

I really don't know much about all of this stuff, and ANY help would be very appreciated!

Please let me know if I need to give any more info.


Solution

  • I was able to figure it out! Here's what I did:

    NSString *html = [animal description];
    [self.animalView.animalDesciption loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];