這是我如何展示UIAlertView中和委託clickedButtonAtIndex -ARC和UIAlertView中:無法識別的選擇發送到實例
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"title"
message: @"message"
delegate: self
cancelButtonTitle: @"Cancel"
otherButtonTitles: @"Continue", nil];
[alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
//something
}
這段代碼工作完全沒有ARC。但隨着ARC它拋出這個錯誤 - 終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因是:「 - [__ NSCFType alertView:clickedButtonAtIndex:]:無法識別的選擇發送到實例0x859d790」
爲什麼委託是投擲任何想法這個錯誤?
委託本身正在被釋放。你如何創建和管理該對象? –
@FirozeLafeer - 調用這段代碼的對象,即自我由ARC發佈。我把它變成了一個財產,現在它似乎工作。謝謝:) – arank