#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文档与程序在同一个文件夹中。我不知道出了什么问题。您的帮助将不胜感激。谢谢