DCRoundSwitchでEXC_BAD_ACCESSが発生する
DCRoundSwitch というUISwitchに表示される オン/オフ の表示をカスタマイズ出来る便利なライブラリがあります。このライブラリは非常に簡単に表示の制御と値監視を行うことが出来るのですが、
DCRoundSwitch *roundSwitch = [[DCRoundSwitch alloc] init];
roundSwitch.on = YES;
[roundSwitch addTarget:self action:@selector(hoge:) forControlEvents:UIControlEventValueChanged]
というような感じで実装を行うと、 EXC_BAD_ACCESS でさくっと落ちてしまいます。
一瞬参照保持していないためかなーと思ったのですが、実際はそうではなく、githubのissueに Crash in ARC project when adding a target after setting .on property というチケットがあがっていました。
I solved it by setting the value AFTER the addTarget call. So
ということなので、
DCRoundSwitch *roundSwitch = [[DCRoundSwitch alloc] init];
[roundSwitch addTarget:self action:@selector(hoge:) forControlEvents:UIControlEventValueChanged]
roundSwitch.on = YES;
で問題なく動作するようになりました。
以上です。