NSString stringWithContentsOfFile持久编译器错误

时间:2013-07-19 14:36:13

标签: iphone ios objective-c

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {
    NSString *a;
    NSString *b;
    //NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Testimony" ofType:@"docx"];
    NSString *nameString = [NSString stringWithContentsOfFile:@"/Testimony.docx"
                                                     encoding:NSUTF8StringEncoding
                                                        errro:NULL];

    NSArray *names = [nameString componentsSeparatedByString:@"\n"];

    for(NSString *n in names){

        NSRange p = [n rangeOfString:@"Tobi" options:NSCaseInsensitiveSearch];
        NSRange r = [n rangeOfString:@"tobi" options:NSCaseInsensitiveSearch];


        if(p.location != NSNotFound){
            //NSLog(@"%@", n);
            a = n;
        }
        if(r.location != NSNotFound){
            //NSLog(@"%@", n);
            b = n;
        }

    }
    if([a caseInsensitiveCompare:b] == NSOrderedAscending){
        NSLog(@"a %@ comes before b %@", a, b);
    }

}
return 0;
}

编译器一直给我“没有已知的选择器类方法”错误。 word文档与程序在同一文件夹中。我不知道出了什么问题。非常感谢您的帮助。感谢

1 个答案:

答案 0 :(得分:0)

您通过

输入拼写错误和错误拼写错误
  

errro

NSString *nameString = [NSString stringWithContentsOfFile:@"/Testimony.docx"
                                                     encoding:NSUTF8StringEncoding
                                                        error:NULL];