0
私はビューの配列で塗りつぶすためのStackを持っています。NSStackViewをNSArrayとNSMutableArrayで塗りつぶします。
_countViewArray = [[NSArray alloc] init];
_countViewArray = @[self.a.view,self.b.view,self.c.view];
_stackView = [NSStackView stackViewWithViews:_countViewArray];
いいですね。 この配列を変更可能な配列に置き換えるにはどうしたらいいですか?
私は「ダイナミック」スタックビューのこのコードを試してみましたが、最終的には単純な配列に可変配列を変換しますが動作しません:consolleで
_mutableCountViewArray = [[NSMutableArray alloc] init];
[_mutableCountViewArray addObject:@[self.a.view]];
if (caseCondition){
[_mutableCountViewArray addObject:@[self.b.view]];
}
[_mutableCountViewArray addObject:@[self.c.view]];
_countViewArray = [_mutableCountViewArray copy];
_stackView = [NSStackView stackViewWithViews:_countViewArray];
を私は持っている可変配列印刷する場合:
(
(
"<NSView: 0x600000121ea0>"
),
(
"<NSView: 0x600000120780>"
,
(
"<NSView: 0x60000a0>"
)
)
を
どうすれば解決できますか?
お世話になります。私は冗長感を理解していません。最初のコードブロックは可変配列ではなく、配列の2番目のallocは理解されています... – Joannes
@alfioal私はあなたが '_countViewArray = [[NSArray alloc] init];'行を安全に削除できることを意味します最初のスニペット)次の行で '_countViewArray'に別の値を再度割り当てるからです...これが意味をなさないことを祈っています:) – Alladinian
ああ、大丈夫です!わかりました! – Joannes