NSString For Capturing Title and Description of WP Article?

Discussion in 'iOS Programming' started by newtoiphonesdk, Aug 25, 2010.

  1. newtoiphonesdk macrumors 6502a

    Jul 30, 2010
    I am taking what I have learned with NSString for getting the currentURL of a webview, and incorporating it into the JSON Format String for FBConnect Publishing to Wall. Is there any way of capturing the Title and Description of a Wordpress Article as an NSString?
    In the FBConnect Post To Wall Format, how do I put in an NSString for one of the HREF? This is the format:
    dialog.attachment = @"{\"name\":\"Facebook Connect for iPhone\","
    		"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}";
    And I would like to take the site, and replace it with the currentURL NSString, and then also, find a way to get an NSString for the Title of whatever the blog is on the current article the WebView shows. Does that make sense?

    OK, I changed
    name\":\"Facebook Connect for iPhone\","
    name\":\"Facebook Connect for iPhone\","
    and then put the currentURL at the end of the string.
    This allowed me to put in the currentURL for the link that clicking on the Name will take you to. However, I would like the Name to be the current Title for whatever blog article the user is currently on. How do you go about doing this?
  2. ianray macrumors 6502

    Jun 22, 2010
    See UIWebView method stringByEvaluatingJavaScriptFromString. It seems like you will have to run some javascript to do what you want.
  3. newtoiphonesdk thread starter macrumors 6502a

    Jul 30, 2010
    Thanks. I'll check that out
    I checked out stringByEvaluatingJavaScriptFromString. In the button for emailing I made the code to look like this for part of it:
    {self.currentURL = sermons.request.URL.absoluteString;
    	self.title = [sermons stringByEvaluatingJavaScriptFromString:@"document.title"];
    This way I can get the currentURL of the webview, and also the Title for the article the webview is currently on.
    In the body of the email I can set it to
    NSString *emailBody = [NSString stringWithFormat:@"%@", self.title];
    NSString *emailBody = [NSString stringWithFormat:@"%@", self.currentURL];
    Either of those will work to pull in the Document Title, or the current URL of the webView. What I would like to do is have both of these. I tried doing an stringByAppendingString, but got the Warning that NSString may not respond to stringWithFormat+stringByAppendingString and it crashed the App when I tried. Is there a way I can get all of these to work?
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Post the code that doesn't work.

    You've described your code, but we can't debug descriptions of code.

    We need to see the actual code.
  5. newtoiphonesdk thread starter macrumors 6502a

    Jul 30, 2010
    I got that part working, just trying now to figure out how to pull the innertext with just the text of the article and not the rss button and everything else in the HTML not associated with the article text

Share This Page