Reputation: 1951
Ok so I am trying to integrate twitter into my iPhone app. I have a UIWebView, and when the user presses the tweet button, I would like the current url to be prefilled into a tweet using the twitter addURL method. The problem is that the current url is formatted for mobile devices, and I would like tweets to show the full version of the website. All of the tweets would link to the same domain, so here are the link formats that I am dealing with.
Mobile URL: http://www.website.com/mobile/news/123456
Fullsite URL: http://www.website.com/podium/default.aspx?t=204&nid=123456
What I have done so far (just showing part of the twitter integration code):
[twitter addURL:[NSURL URLWithString:[NSString stringWithFormat:@"www.website.com/podium/default.aspx?t=204&nid="]]];
So my question is, is there a way to take the identifying numbers from the mobile site and append them onto the fullsite that will be included in the tweet? I just don't know much about parsing url's (if that is what needs to be done in this situation) so any help is appreciated. Thanks
Upvotes: 1
Views: 309
Reputation: 14694
You are very close. Because you are using stringWithFormat you just need to add a format string to your argument. Let's say that you have the id as an int variable called theID:
int myID = 123456; [twitter addURL:[NSURL URLWithString:[NSString stringWithFormat:@"www.website.com/podium/default.aspx?t=204&nid=%i", myID]]];
I suggest taking a look at the String Programming Guide for clarification.
Upvotes: 1