【问题标题】:NSMutableArray accessing dataNSMutableArray 访问数据
【发布时间】:2013-01-03 20:34:15
【问题描述】:

是否可以在Array中获取随机按钮的标签?

- (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

【问题讨论】:

    标签: iphone sdk nsmutablearray


    【解决方案1】:

    -

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

    【讨论】:

      猜你喜欢
      • 2013-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多