gpt4 book ai didi

ios - ARC 和 UIAlertView : unrecognized selector sent to instance

转载 作者:技术小花猫 更新时间:2023-10-29 11:02:27 24 4
gpt4 key购买 nike

这是我如何显示 UIAlertView 和委托(delegate) clickedButtonAtIndex -

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”

关于委托(delegate)为何抛出此错误的任何想法?

最佳答案

您的委托(delegate)已被解除分配。仔细检查您的代码以确保显示警报并将自身设置为委托(delegate)的对象以某种方式被保留(即:您应用中的某些内容对它有很强的引用)。

关于ios - ARC 和 UIAlertView : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8514548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com