Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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:
Code:
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
Code:
name\":\"Facebook Connect for iPhone\","
		"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\
to
Code:
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

macrumors 6502
Jun 22, 2010
452
0
@
...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

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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:
Code:
{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
Code:
NSString *emailBody = [NSString stringWithFormat:@"%@", self.title];
OR
Code:
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

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
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

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.