从in-loop到达属性

时间:2015-09-19 11:17:05

标签: ios objective-c for-in-loop

我正在创建一个简单的骰子游戏,现在我正试图通过for循环来触及我的属性。这有意义吗?这是代码,问题显示在最后一行。

- (IBAction)throwDice {
    //Create an array with the image objects
    NSArray *diceNr = @[_dieOne, _dieTwo, _dieThree, _dieFour, _dieFive];

    //For each image object, get a random number 0-5 
    //and place the associated image for this number in the image object

    for (id dices in diceNr) {
        NSUInteger dieIndex = arc4random_uniform(6);
        NSArray *diceValue = @[@"one", @"two", @"three", @"four", @"five", @"six"];
        NSNumber *dice = diceValue[dieIndex];
        self.dices.image = dice;        
    }
}

0 个答案:

没有答案