我正在尝试显示一个随机的 plist 字符串,但是当我 NSLog 显示的所有内容都是“(null)”时,也许我在代码中做错了:
- (void) viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForResource:
@"small" ofType:@"plist"];
NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSMutableArray *plistArray = plistDict[@"Value"];
NSInteger randV = arc4random_uniform(plistArray.count); // randV is from 0 to number of strings -1 in array
[super viewDidLoad];
self.correctWord = [plistArray objectAtIndex:randV];
[self setupHangmanWord:self.correctWord];
}
这是我的 small.plist 文件: image
任何帮助都会很棒..谢谢