Question

I am Working on an RSS app where it needs to send the url of the article through a message. I have this code so far,

 MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init] ;{
            if([MFMessageComposeViewController canSendText])
            {
                controller.body = @"Check Out This Informtaion, %@", [NSURL URLWithString:self.feedItem[@"url"]];
                controller.recipients = [NSArray arrayWithObjects: nil];
                controller.messageComposeDelegate = self;
                [self presentModalViewController:controller animated:YES];
            }}

And it will work, it opens up the Messages in-app, but all it says in the message is

Check Out This Information, %@

When I do the same

[NSURL URLWithString:self.feedItem[@"url"]];

for opening up the page in Safari, it works, so that is correct, but I don't know how to fix it, please help.

Was it helpful?

Solution

This line:

controller.body = @"Check Out This Informtaion, %@", [NSURL URLWithString:self.feedItem[@"url"]];

is equivalent to

controller.body = @"Check Out This Informtaion, %@";
[NSURL URLWithString:self.feedItem[@"url"]];

…because the two statements are executing independently.

As user2056143 pointed out, you’re missing an NSString -stringWithFormat: around your values. I.e.:

controller.body = [NSString stringWithFormat:@"Check Out This Informtaion, %@", [NSURL URLWithString:self.feedItem[@"url"]]];

OTHER TIPS

Change body to :

controller.body = [NSString stringWithFormat:@"Check Out This <a href=\"%@\">Information<\a>", self.feedItem[@"url"]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top