2016-05-17 11 views
1

作成したボタンをNSMutabledictionaryに追加しました。ちょうどNSDictionaryを繰り返し、ボタンを1つの変数に保存します。辞書からボタンを取得する

UIButton *word= [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    . 
    . 
    . 
    [self.buttonsDict setObject:word forKey:[NSNumber numberWithInt:rownumber]]; 

    for (int j = 0; j<self.buttonsDict; j++) { 

int index = [self.buttonsDict objectForKey:rownumber]; 
} 

インデックスではなく、辞書からボタンを取得するために使用するものを指定します。

答えて

0

私はあなたが辞書のすべてのキーを反復したいと思っていますか? NSDictionaryのkeyEnumeratorを使いたいという点で、最も簡単な方法ではなく、すべてのキーを繰り返し処理し、各キーを使って各ボタンを取得することです。

for (NSNumber *key in self.buttonsDict.allKeys) { 
    UIButton *button = [self.buttonsDict objectForKey:key]; 
    // Do whatever with the button 
} 
関連する問題