-2
#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文檔與程序位於同一文件夾中,我不知道有什麼問題。您的幫助將不勝感激。由於NSString stringWithContentsOfFile持久性編譯器錯誤
[我們關閉所有的錯字問題 「太本地化」(以前)。(HTTP錯字和拼寫錯誤錯誤:/ /meta.stackexchange.com/questions/167342/close-all-the-typo-questions)缺少必要的「最小理解」(顯然是......) – 2013-07-19 14:58:11
當然,你應該... – Dan
這個問題應該刪除,因爲它是以錯字爲基礎的,對未來的搜索者沒有任何用處。 –