-3

配列内のランダムボタンのタグを取得することは可能ですか?

- (IBAction)actionButtonPressed:(id)sender
{
    NSUInteger randomIndex = arc4random()% [_allButtons count];
    NSLog(@"%d", randomIndex);
    NSLog(@"tag: %@",[_allButtons objectAtIndex:randomIndex]);
}

ログから私はこれを取得します:

UIRoundedRectButton:.... frame = (110 98; 50 44); opaque = NO; **tag = 5**; layer = CALayer.....

ランダムボタンからタグを取得することは可能ですか?

編集:申し訳ありませんが_allButtonsはNSMutableArrayです

4

1 に答える 1

2

-

(IBAction) actionButtonPressed:(id)sender {

    NSUInteger randomIndex = arc4random()% [_allButtons count];

    NSLog(@"%d", randomIndex);

    NSLog(@"tag: %d", [[_allButtons objectAtIndex:randomIndex] tag]);

}
于 2013-01-03T20:35:34.940 に答える