ボタン1とボタン2の2つのボタンがあります。タッチされた対応するボタンごとに NSSet を作成し、ボタン 2 がタッチされたときに set1 の値を表示したい、またはその逆を行いたい。ボタン 1 が押されるとセット 1 のみが印刷され、ボタン 2 が押されるとセット 2 のみが印刷されます。ボタン2が押されたときに表示/使用できるように、ボタン1アクションで作成されたセットを保持するにはどうすればよいですか。私の簡単なコードを見てください
実装では、私は持っています:
- (IBAction)button1:(UIButton *)sender {
//somecode
selectionButton1 = [[NSMutableArray alloc ] initWithObjects:@0,@1,@1,@4,@6,@11, nil];
NSMutableSet *set1 = [NSMutableSet setWithArray: selectionButton1];
NSLog(@"selectionButton1 = %@", set1);
NSLog(@"selectionButton2 = %@", set2);
}
- (IBAction)button2:(UIButton *) sender {
//somecode
selectionButton2 = [[NSMutableArray alloc ] initWithObjects:@0,@5,@6,@7,@8,@10, nil];
NSMutableSet *set2 = [NSMutableSet setWithArray: selectionButton2];
NSLog(@"selectionButton1 = %@", set1);
NSLog(@"selectionButton2 = %@", set2);
}