0

I have an iOS app where I read the data from the website in a UIWebView which is hidden from the user (don't worry its my own website), parse the data from the resulting HTML, read specific info and put it into NSArrays to display in UITable. All is well and good and works in iOS.

- (void)webViewDidFinishLoad:(UIWebView *)webView2
{
    NSLog(@"webViewDidFinishLoad ...");

    NSString *htmlSourceCodeStr = [webView2 stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];
}

I was thinking of porting the same app to tvOS. Surprise Surprise UIWebView isn't available in tvOS.

Is there a way for me to load / Fetch website data somehow in tvOS, parse and read the resulting HTML? Is that even possible?

Community
  • 1
  • 1
Sam B
  • 27,273
  • 15
  • 84
  • 121

2 Answers2

1

Just make the HTTP request directly using NSURLSession. You'll get the HTML back as NSData and can parse it from there just like before. You should probably do the same in your iOS app: if you're not going to show the HTML to the user then there's no point in using something as heavyweight as a web view.

Justin Voss
  • 6,294
  • 6
  • 35
  • 39
  • good man you are absolutely right. With NSURLSession I was able to get all the data that I needed in tvOS. Thanks man – Sam B Jul 07 '16 at 23:16
0

To answer your question, no (kind of), it is not possible at the moment. The link you posted pretty much answered your question - there may be a way using private APIs or using UIWebViews (maybe), but Apple would never allow it to be published. Not only that, but WebKit isn't available either. This pretty much sums it up:

Companies hoping to leverage a universal HTML5/CSS/JS-based UI for multiple platforms may no longer find this option viable. They will need to rethink their strategy for providing a cohesive branded experience on multiple platforms while still writing native apps for those platforms. That’s not to say that someone wouldn’t be able to try compiling WebKit and creating their own view within to render HTML. Certainly there are companies with the manpower and resources to do this. I’m not certain those apps wouldn’t get rejected, though.

Very sorry I couldn't give you the answer you were looking for. Good luck :)

Sources

Community
  • 1
  • 1
CoolPenguin
  • 1,215
  • 12
  • 21