尝试使用CHCSV解析器时,如下所示:

#import "CHCSVParser.h"
....

- (IBAction)hi:(id)sender {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"nood" 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;
    }

}


我得到错误:


  选择器arrayWithContentsOfCSVFile:encoding:error的未知类方法:


我已经包含了CHCSV标头,但此错误仍然发生。
这个问题与this完全相同,但是没有得到回答,因此请不要将其标记为重复。

最佳答案

The header from github似乎没有这种方法。您的选择似乎是:

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


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

关于ios - CHCSV分析器错误:选择器'arrayWithContentsOfCSVFile:encoding:error:'的未知类方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18293085/

10-11 22:27
查看更多