错误使用CHCSVparsing器:没有已知的类方法select器'arrayWithContentsOfCSVFile:encoding:error:'

我正在使用CHCSVparsing器来创build一个使用csv的数组。 但是,我收到这个错误:

没有已知的select器的类方法arrayWithContentsOfCSVFile:encoding:error:'

这是我如何创build我的数组:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"csv"]; NSError *error = nil; NSArray *rows = [NSArray arrayWithContentsOfCSVFile:path encoding:NSUTF8StringEncoding error:&error]; if (rows == nil) { //something went wrong; log the error and exit NSLog(@"error parsing file: %@", error); return; } 

谢谢您的帮助。

github的头文件似乎没有这样的方法。 您的select似乎是:

 + (instancetype)arrayWithContentsOfCSVFile:(NSString *)csvFilePath; + (instancetype)arrayWithContentsOfCSVFile:(NSString *)csvFilePath options:(CHCSVParserOptions)options; 

请注意,都没有encoding:参数。

你有没有包含CHCSVParser.h? 它声明arrayWithContentsOfCSVFile方法来扩展NSArray。