简体   繁体   English

通过Objective-C将数据插入HTML

[英]Inserting data into HTML via Objective-C

I want to add a hot html link to an email in objective-c. 我想在Objective-C中将热html链接添加到电子邮件中。 I know that the way it would typically work if I had a specific url would be something along the lines of: 我知道,如果我有特定的网址,通常可以正常工作的方式如下:

[composer setMessageBody:[NSString stringWithFormat:@"Example text, 
<a href=\"google.com\">Link Name</a> More example text"];

But I want to have a hot link with a custom generated url as both the title of the link and the website of the link, so something more like: 但是我想有一个带有自定义生成的URL的热链接,作为链接的标题和链接的网站,所以更像是:

[composer setMessageBody:[NSString stringWithFormat:@"Example text, 
<a href=%@>%@</a>", self.link, self.link];

But this is crashing on me. 但这使我崩溃了。 Ideas? 有想法吗?

You didn't close this statement: 您没有关闭此语句:

[composer setMessageBody:[NSString stringWithFormat:@"Example text, 
<a href=%@>%@</a>", self.link, self.link];

Needs another close square bracket at the end. 最后需要另一个封闭的方括号。

Plus you should have wrapped the href value in quotes, escaped of course. 另外,您应该将href值括在引号中,当然可以转义。

\" value \"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM