我正在尝试将 aNSString
分解为逗号分隔的组件。不知何故,我NSString
包含 25000 个组件总是返回 25.500 个值,其中 500 个是空的NSStrings
。这是我的代码的样子:
NSString* fileContents = [NSString stringWithContentsOfFile:filePath
encoding:NSUTF8StringEncoding
error:nil];
/* do stuff */
NSMutableArray* components =
[NSMutableArray arrayWithArray:
[fileContents componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@",\n\r "]]];