-3
我在支持文件中保存了一個文件。現在我想將該文件中的文本複製到xcode中的文本字段中。請幫助我解決這個問題。如果可能,請發佈任何代碼。 我已經使用了下面的代碼,但我無法訪問。如何從xcode項目中的本地文本文件中獲取文本
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"iPhone.txt" ofType:@"txt"];
NSString *textData = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
NSLog(@"Some text from a file of %@", textData);
NSLog(@"The length of the string is %u",[textData length]);
錯誤:
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "FirstInMacViewController" nib but the view outlet was not set.' * First throw call stack: