UIWEBVIEW- receive string from url

Discussion in 'iOS Programming' started by arme, Sep 23, 2008.

  1. arme macrumors member

    Joined:
    Sep 15, 2008
    #1
    i want receive string from url. i can receive a html but i don't want to load html . how?
     
  2. mccannmarc macrumors 6502

    mccannmarc

    Joined:
    Aug 15, 2008
    Location:
    Manchester, UK
    #2
    if you dont want to show a html page then why are you using a UIWebView???? :confused:
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    NSURLConnection and NSURLRequest are what you want. I use these to download the source code for web pages which I then parse.
     
  4. arme thread starter macrumors member

    Joined:
    Sep 15, 2008
    #4
    i need connect to url for receive information login. for example check user and pass
     
  5. amishra7 macrumors newbie

    Joined:
    Aug 29, 2008
    #5
    Iphone Programs returns to home screen automaticcaly

    Hi All

    I am new to Iphone Development and Objective C.I had made an application in which i get the users lat long as soon as he open my location. And on the basis of their lat long I have to perform various thing.My Program is running fine on the Iphone Simulator 2.1. But when I tried to run it on the real device its always bring me back to the home screen of my application.

    I am looking forward to hear from you people. Please do reply as i already waisted enough no of days on this issue.

    Thanks in advance.
    Amit
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Your program is crashing. You should look at the crash logs in the Organiser window to work out why.
     
  7. arme thread starter macrumors member

    Joined:
    Sep 15, 2008
    #7
    can you help me that use which function NSURLRequest that receive a string from url
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    I'm afraid that I can't understand what you want to do, probably because English is not your first language. Can you please outline what you are doing clearly and simply. You would use NSURLConnection to download data from a URL source. If you are trying to login to a website via a login form or similar this could, potentially, be done use NSURLConnection and a NSMutableURLRequest in which you would set the headers to correspond to a form POST.

    All of this is covered in the documentation which I suggest you read. You can read about the URL loading system here.
     
  9. arme thread starter macrumors member

    Joined:
    Sep 15, 2008
  10. tdog09 macrumors member

    Joined:
    Jul 13, 2008
    #10
    Question...what are you using to parse the webpages you are downloading? I've been looking all over for an html parser. Is one needed for this? Or are you just writing your own parse code?

    I ask because I'm trying to find a nice and effective way to grab certain bits and pieces out of a page.

    Thanks!
     
  11. matthew858 macrumors member

    Joined:
    Apr 15, 2008
    Location:
    Sydney, Australia
    #11
    I have previously posted about this and was wondering if anyone could provide me with some coding examples? I have an RSS feed and I want the link to the full story to open up in my inbuilt web browser, but I don't know how to do this using NSURL as I am new to Objective c.
     
  12. robotspacer macrumors member

    Joined:
    Jun 25, 2007
    #12
    The main thing you need to do is set a delegate for your web view. Something like webView.delegate = self;

    Then you can add this to do something with the URL:
    Code:
    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    	if (navigationType == UIWebViewNavigationTypeLinkClicked) {
    		// do something with request.URL
    		return NO;
    	}
    	return YES;
    }
     
  13. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #13

    I do it all by hand: there is no generic HTML parser. If you can 100% guarantee that the document is valid XML you can use the available XML parser, otherwise you are on your own. I just use a combination of substrings/splits on characters to get what I want from the document.
     
  14. matthew858 macrumors member

    Joined:
    Apr 15, 2008
    Location:
    Sydney, Australia
    #14
    So would you replace:

    --------------------
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];
    --------------------

    With:

    --------------------
    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
    // do something with request.URL
    return NO;
    }
    return YES;
    }
     

Share This Page