Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Code Challenge: Implementing a UIWebView 2/2

Load the previously created 'url' object within the 'webView' object.

I'm not quite sure where to go from here. My code:

UIWebView *webView = [[UIWebView alloc] init]; <br>

/* Write your code below this line */ <br>

NSURL *url = [NSURL URLWithString:@"http://teamtreehouse.com/"]; <br>

[webView requestWithURL: url];

3 Answers

I know the last line is the problem but I'm getting farther than closer, the more I play with it.

Solved. I skipped the part where I needed to create an instance of NSURLRequest before loading it into the WebView.

Would anyone be able to help me.

UIWebView *webView = [[UIWebView alloc] init];
/* Write your code below this line */
NSURL *url = [NSURL URLWithString:@"http://teamtreehouse.com/"];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:urlRequest];

I keep getting a Compilation error. Im not sure where im going wrong.

Hi Daniel,

I've been have trouble with this task as well and have got the same code as you, and kept getting the Complication error.

The task is saying to load the 'url' object with the 'webView', so you don't need reference to 'self.' in the code as it did in the video.

The last line of code should read -

[webView loadRequest:urlRequest];

This pasted for me.

Ahh thank you Steve