-1

我想从警报创建警报。但它崩溃了。我使用代码来创建警报:

{ 
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:inMessage delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}

错误信息是:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSError isEqualToString:]: unrecognized selector sent to instance 0x88b84c0'

看起来 inMessage 已经发布。所以我将 inMessage 更改为 @"test test"。它有效,但出去wait_fences: failed to receive reply:10004003

如何在警报中创建警报?

4

1 回答 1

1

正如其他人在评论中指出的那样,这里的问题是您有一个 NSError 被错误地视为 NSString。

inMessage似乎是你的 NSError 对象。这在编译时会通过类型系统,因为userInfo不知道其元素的类型。

要解决此问题,您可能希望获取错误消息的描述并使用类似的内容显示它

NSString *inMessage = [[userInfo objectForKey:@"NSUnderlyingError"] localizedDescription];
于 2012-06-15T06:27:33.763 回答