每次用新字符串替换字符串时,我会从HTMl
到NSString
获得多个字符串。我试过NSArray
它说NSString
对阵列很强。我希望所有字符串一个接一个地存储在NSString
中。我怎么能这样做?
TFHpple *tutorialsParser = [TFHpple hppleWithHTMLData:nsData];
NSString *tutorialsXpathQueryString = @"//div[@id='NewsPageArticle']/p/span ";
// NSString *tutorialsXpathQueryString = @"//div[@class='entry']/ul/li/a";
NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:tutorialsXpathQueryString];
// 4
NSMutableArray *newTutorials = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in tutorialsNodes) {
// 5
Tutorial *tutorial = [[Tutorial alloc] init];
[newTutorials addObject:tutorial];
// 6
tutorial.title = [[element firstChild] content];
答案 0 :(得分:2)
您应该使用NSMutableString
附加字符串
NSMutableString aString = [[NSMutableString alloc]initWithString:yourHTMLString];
[aString appendString:parsedHTMLString];