Oto jak pokażę UIAlertView i clickedButtonAtIndex delegata -ARC i UIAlertView: nierozpoznany selektor wysyłane do instancji
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
}
Ten fragment kodu działa doskonale bez ARC. Ale z ARC zgłasza ten błąd - Zakończenie aplikację spowodowane nieprzechwyconego wyjątku „NSInvalidArgumentException”, powód: „- [__ NSCFType alertView: clickedButtonAtIndex:]: selektor nierozpoznany wysyłane do instancji 0x859d790”
Wszelkie pomysły, dlaczego delegat jest rzucanie ten błąd?
Sam delegat jest zwalniany. Jak budujesz i zarządzasz tym obiektem? –
@FirozeLafeer - obiekt, który wywoływał ten fragment kodu, tj. Self, został zwolniony przez ARC. Zrobiłem to jako własność i teraz wydaje się działać. Dzięki :) – arank