NSScanner

NSString *tmp;
NSArray *lines; /*将文件转化为一行一行的*/
lines = [[NSString stringWithContentsOfFile:@"testFileReadLines.txt"]
componentsSeparatedByString:@”\n”];

NSEnumerator *nse = [lines objectEnumerator];

// 读取<>里的内容
while(tmp = [nse nextObject]) {
NSString *stringBetweenBrackets = nil;
NSScanner *scanner = [NSScanner scannerWithString:tmp];
[scanner scanUpToString:@"<" intoString:nil];
[scanner scanString:@"<" intoString:nil];
[scanner scanUpToString:@">" intoString:&stringBetweenBrackets];

NSLog([stringBetweenBrackets description]);
}

你可能感兴趣的:(Scanner)