RSS からのニュースの説明を解析すると、次の形式のリンクがあります。
2012 年 4 月 4 日の小さな発明 (index.php?option=com_content task=view id=157 Itemid=100)。
リンクテキスト付きのハイパーリンクを表示したい:
2012 年 4 月 4 日の小さな発明
およびリンクアドレス:
index.php?option=com_content task=view id=157 Itemid=100
どうすればいいのですか?
RSS からのニュースの説明を解析すると、次の形式のリンクがあります。
2012 年 4 月 4 日の小さな発明 (index.php?option=com_content task=view id=157 Itemid=100)。
リンクテキスト付きのハイパーリンクを表示したい:
2012 年 4 月 4 日の小さな発明
およびリンクアドレス:
index.php?option=com_content task=view id=157 Itemid=100
どうすればいいのですか?
次のように必要な文字列を取得できます。
NSString *string = [NSString stringWithString:@"Little invention of the 4 april 2012 (index.php?option=com_content task=view id=157 Itemid=100)"];
int linkStartIndex = [string rangeOfString:@"(" options:NSBackwardsSearch].location;
NSString *name = [string substringToIndex:linkStartIndex];
NSString *adress = [string substringWithRange:NSMakeRange(linkStartIndex+1, string.length-linkStartIndex-2)];
NSLog(@"\nname = [%@], \naddress = [%@]", name, adress);
UIWebView を使用して表示する場合よりも、webView の html に次の文字列を追加します。
NSString *linkTag = [NSString stringWithFormat:@"<a href=\"%@\">%@</a>", adress, name];