2012-08-23 53 views
-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:

回答

1

该错误无关,与你发布的代码。看起来你错误地断开了你的笔尖的出口。打开你的笔尖,用鼠标右键从文件的所有者拖动到顶层视图,并连接view插座。

相关问题