一个NSString中有多个字符串

时间:2012-12-28 13:14:51

标签: iphone ios ipad

每次用新字符串替换字符串时,我会从HTMlNSString获得多个字符串。我试过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];

1 个答案:

答案 0 :(得分:2)

您应该使用NSMutableString附加字符串

NSMutableString aString = [[NSMutableString alloc]initWithString:yourHTMLString];
[aString appendString:parsedHTMLString];