0

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.

Mike D
  • 4,938
  • 6
  • 43
  • 99
Steve
  • 205
  • 3
  • 14

2 Answers2

2

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"]]];
Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
  • I will try this in a few minutes, don't have access to my Mac right now thanks – Steve Mar 15 '13 at 01:02
  • While I am thinking about it, do y'all know of a stack-overflow question for implementing the share button like in the safari ios app. The one with icons and the different sharing options. – Steve Mar 15 '13 at 01:07
  • Yep—search for UIActivityViewController – Noah Witherspoon Mar 15 '13 at 02:32
1

Change body to :

controller.body = [NSString stringWithFormat:@"Check Out This <a href=\"%@\">Information<\a>", self.feedItem[@"url"]];
Jesse Rusak
  • 56,530
  • 12
  • 101
  • 102
  • 1
    I've fixed the formatting (start a line with 4 spaces to make it code) but I don't think you need to use HTML for this; the message body probably just plain text. – Jesse Rusak Mar 15 '13 at 00:14