1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Problem in accessing content of a web by passing variable

Discussion in 'iPhone/iPad Programming' started by iphonejudy, Dec 11, 2008.

  1. macrumors 6502

    iphonejudy

    #1
    Hi,


    I need to display a content of a website by passing a value.

    my link is
    http://www.xxx.com/xxx.aspx?country=code;

    here i want to pass a code as a variable.(because code value is 100,101,102).According to the value the content will be changed.

    HTML:
    So i get a value of code in  a textfield and store it in a variable called code.
    
    code=textfield.text; 
    
    
    //To concatenate url with "code"
    
    NSString *urlContents =	[NSString stringWithFormat:
    				        @"http://www.xxx.com/xxx.aspx?country=? 
                                            %@",code ];
    
     urlContents having(http://www.xxx.com/xxx.aspx?country=100).
    
    //To display Contents
    
     *NSString *urlContents1 = [NSString stringWithContentsOfURL:
    				      [[NSURL alloc] initWithString:urlContents]];
    
     I use a textview to display a content, so ,
    
    textview.text=urlContents1;
    
    
    								
    But i cannot get result.

    Can anybody please give me the code.
    Regards
    judy
     
  2. macrumors 6502

    #2
    You need to provide more information about what's "not working". What have you tried so far to debug this?

    Also don't use xxx.com as an example domain, it redirects to porn. http://www.example.com is reserved for the purpose of examples, use that.
     
  3. Moderator

    dejo

    Staff Member

    #3
    On first pass, I see a problem with your urlContents string creation.

    Code:
    NSString *urlContents =	[NSString stringWithFormat:
    				        @"http://www.xxx.com/xxx.aspx?country=? 
                                            %@",code ];
    What is with the "country=?" ? That is going to generate "country=?100", for example.

    Try this instead:

    Code:
    NSString *urlContents =	[NSString stringWithFormat:
    				        @"http://www.xxx.com/xxx.aspx?country=%@", 
                                            code ];
     
  4. macrumors 6502

    iphonejudy

    #4
    Thanks.I finished
     

Share This Page