需要对输出字符串设置格式,这样可以将URL和内容分开显示。请指教。
代码:NSLog(@"Description %@", string);
输出字符串:
2013-07-28 11:13:59.083 RSSreader[4915:c07] Description
http://www.apple.com/pr/library/2013/07/23Apple-Reports-Third-Quarter-Results.html?sr=hotnews.rss
Apple today announced financial results for its fiscal 2013 third quarter ended
June 29, 2013. The Company posted quarterly revenue of $35.3 billion and quarterly
net profit of $6.9 billion, or $7.47 per diluted share.
Apple sold 31.2 million iPhones, which set a June quarter record.
要格式化输出字符串,可以使用printf函数或者NSString的stringWithFormat方法。
例如,你可以使用以下代码来格式化输出字符串:
NSLog(@"URL: %@", urlString);
NSLog(@"Content: %@", contentString);
或者:
NSLog(@"URL: %@\nContent: %@", urlString, contentString);
或者:
NSString *formattedString = [NSString stringWithFormat:@"URL: %@\nContent: %@", urlString, contentString];
NSLog(@"%@", formattedString);
还有很多其他的占位符,比如%d表示整数,%f表示浮点数等。详情可以参考Apple的文档:String Format Specifiers。