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

iOS

After setting a webview as a property, do we have to init it before using it ?

I can see Amit set webview as a property in h file, then in m file when he used it in viewdidload method, he use it directly as "self.webview" without initializing it , and it just worked!

I am very confused. Should the teacher write something like

self.webview=[[UIWebView alloc] init];

before using it ?

1 Answer

Hi Jack,

You only ever need to initialize classes if you're creating them programmatically, if you add the view using the storyboard editor Xcode will automatically add the constructor code in when it's compiling your code.

thanks chris! i have considered this possibility, but if this is the case, Atim should have sent this webview to WEAK because this controller doesn't own it ,instead, the view owns it. Am I right?