标签:
NSString *path = [[NSBundle mainBundle] pathForResource: @"type" ofType:@"csv"]; NSString* fileContents = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
// first, separate by new line NSArray* allLinedStrings = [fileContents componentsSeparatedByString:@"\r\n"]; // then break down even further _poiTypes = [[NSMutableDictionary alloc] initWithCapacity:[allLinedStrings count]]; for (int i = 0; i NSString* strsInOneLine = [allLinedStrings objectAtIndex:i]; NSString *trimmedString = [strsInOneLine stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSArray* singleStrs = [trimmedString componentsSeparatedByString:@","]; NSString *strType = [singleStrs objectAtIndex:0]; NSString *strValue = [singleStrs objectAtIndex:1]; NSString *strValue1 = [strValue substringToIndex:[strValue length]-2]; [_poiTypes setObject:strType forKey:strValue1]; } }
标签:
原文地址:http://www.cnblogs.com/wcLT/p/4677972.html