Tesseract初始化错误

时间:2015-01-03 20:34:19

标签: tesseract

使用此github页面https://github.com/robmathews/OCR-iOS-Example,我下载并安装了repo并按照说明进行操作。尝试在手机上启动.xcodeproj文件在Tesseract.mm中提供了一个例外:

- (id)initWithDataPath:(NSString *)dataPath language:(NSString *)language {
    self = [super init];
    if (self) {
        _dataPath = dataPath;
        _language = language;
        _variables = [[NSMutableDictionary alloc] init];

        [self copyDataToDocumentsDirectory];
        _tesseract = new tesseract::TessBaseAPI();

        BOOL success = [self initEngine];
        if (!success) {
            return NO;
        }
    }
    return self;
}

return NO行,xcode说Cannot initialize return object of type 'Tesseract *' with an rvalue of type 'BOOL' (aka 'bool')

我做错了什么?

1 个答案:

答案 0 :(得分:2)

NO是bool值。返回类型是(如您所定义的)id(应为instancetype

您必须在那里返回nil