Why to set get method


#1

[code]
@implementation WebViewController

  • (void)loadView
    {
    CGRect screenFrame = [[UIScreen mainScreen] applicationFrame];
    UIWebView *wv = [[UIWebView alloc] initWithFrame:screenFrame];
    [wv setScalesPageToFit:YES];

    [self setView:wv];
    }

  • (UIWebView *)webView
    {
    return (UIWebView *)[self view];
    }[/code]

Why to set access method?


#2

Please rephrase your question.


#3

I don’t know why i have to write the code like this.

i think it can be rewrite like this

[code]
@implementation WebViewController
@synthesize webView

  • (void)loadView
    {
    CGRect screenFrame = [[UIScreen mainScreen] applicationFrame];
    webView = [[UIWebView alloc] initWithFrame:screenFrame];
    [webView setScalesPageToFit:YES];

    [self setView:webView];
    }[/code]

but it don’t work,i don’t know why


#4

What error message are you getting exactly?

Meanwhile, please go back and review the basic concepts, especially properties.


#5

[quote=“ibex10”]What error message are you getting exactly?

Meanwhile, please go back and review the basic concepts, especially properties.[/quote]

I can’t see the view of webView


#6

You mean it’s a blank view? You need to load it with contents.