PDA

View Full Version : NSString For Capturing Title and Description of WP Article?




newtoiphonesdk
Aug 25, 2010, 12:19 PM
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\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\","
"\"caption\":\"Caption\",\"description\":\"Description\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=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\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\ to
name\":\"Facebook Connect for iPhone\","
"\"href\":\"%@\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?



ianray
Aug 25, 2010, 04:32 PM
...I would like the Name to be the current Title for whatever blog article the user is currently on.

See UIWebView method stringByEvaluatingJavaScriptFromString. It seems like you will have to run some javascript to do what you want.

newtoiphonesdk
Aug 25, 2010, 04:46 PM
Thanks. I'll check that out
UPDATE:
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];
OR
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?

chown33
Aug 26, 2010, 03:10 PM
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?

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.

newtoiphonesdk
Aug 26, 2010, 03:15 PM
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