想寫一個UIAlertView的管理類,就繼承了NSObject, AlertHelper
寫完後在ViewController中調用:
AlertHelper *alertHelper = [[AlertHelper alloc] init];
[alertHelper show];
~結果,在AlertHelper的 UIAlertView的delegate函數老是回調不到
原因:
由於是在ARC模式中,一旦show完,alertHelper就被釋放了,再到回調的時候已經能夠沒有這個對象了。
解決方法:
改變在ViewController中寫法
採用
@property(nonatomic,strong)AlertHelper *alertHelper;
調用的時候
self.alertHelper = [[AlertHelper alloc] init];
[self.alertHelper show];