0

每次将字符串替换为新字符串时,我都会从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];
4

1 回答 1

2

您应该NSMutableString用于附加字符串

NSMutableString aString = [[NSMutableString alloc]initWithString:yourHTMLString];
[aString appendString:parsedHTMLString];
于 2012-12-28T13:19:22.100 回答