Search code examples
iosnsstringnsurlmfmailcomposer

NSUrl with hyperlink inside a NSString?


So pretty much what I am doing is attempting to add a NSUrl inside of a NSString to pass to a MFMailComposeController. I want the URL in the message field to have a hyperlink but if I just put a basic link inside a NSString, it won't hyperlink for me.

What am I doing wrong?

Thanks!


Solution

  • You're trying to put a square peg into a round peg (yes peg). NSString and NSUrl are both classes. NSString objects do not know how to hold an NSUrl object. They only know how to hold a string of characters.

    If your application supports it, just put the URI address in the NSString. For example:

    NSString someText = @"Please visit http://stackoverflow.com for more information.";