我有一个可以包含一个或多个字符串的数组。这是我的输入:
51403423 0001051629 1302130622 TOMTOM101订购51403423-3-179178687:ontvangen
51403423 0001051629 1302130644 TOMTOM241订购51403423-3-179178687:gestart
51403423 0001051629 1302130645 TOMTOM241订购51403423-3-179178687:geschatte aankomst 7:33,57公里运
BES 51403423 0001051629 1302130937 TOMTOM241订单51403423-3-179178687:gestart
51403423 0001051629 1302130951 TOMTOM249 订单 51403423-3-179178687:voltooid
这些字符串是从一个大文本文件中过滤出来的,如下所示:
NSData *tmpData = [NSData dataWithContentsOfURL:[NSURL URLWithString:trackTraceFileUrlName] ];
NSLog(@"%@",trackTraceFileUrlName);
//convert data to string
NSString *tmpString = [[NSString alloc] initWithData:tmpData encoding:NSUTF8StringEncoding];
NSArray *piecesArray = [tmpString componentsSeparatedByString:@"\n"];
NSMutableArray *trackTraceContent = [NSMutableArray arrayWithArray:piecesArray];
NSLog(@"%@",trackTraceContent);
/*Filtering array for referance*/
NSPredicate *findStringWithReference = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",cRText.text];
NSArray *trackTraceContentFiltered = [trackTraceContent filteredArrayUsingPredicate:findStringWithReference];
/*Filtering array for Collected status*/
NSPredicate *findStringWithStatusCollected = [NSPredicate predicateWithFormat:@"SELF contains[c] 'TOMTOM229'"];
NSArray *filteredArrayOnStatusCollected = [trackTraceContentFiltered filteredArrayUsingPredicate:findStringWithStatusCollected]
;
过滤文本文件的结果将是一个包含过滤对象的数组。这将如下所示:
filtersArrayOnStatusCollected:“51403423 0001051629 1302121101 TOMTOM229 订单 51403423-2-477100555:voltooid”
现在我想分离这个对象,这样我就可以把它说 1302121101 的部分放入标签中。我该怎么做?