我正在尝试从 Resources 文件夹中获取随机文本文件以显示在 Textview 中。我不能这样做,因为我无法在 pathForResource:@" 1 " 增量中得到那个1 。我怎样才能在@之后增加那个1。谢谢。
注意:我正在尝试在那里使用 stringb 但它不起作用。
int b=(arc4random()%9)+1;
NSString *stringb = [NSString stringWithFormat:@"%d", b];
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"1" ofType:@"txt"];
if (filePath) {
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
if (myText) {
textView1.text= myText;
}
}