-1

I want to create a alert from a alert. but it crashes. I use under code to create a alert:

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

error message is :

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

it looks like inMessage has been release. so I change inMessage to @"test test". It works but get out wait_fences: failed to receive reply:10004003

How can i do for creating a alert in a alert ?

kevin young
  • 941
  • 2
  • 10
  • 22
  • 2
    IF the NSString is the problem then your shared code will not help us to solve your problem, correct? Please show us your string init and What do you mean by alert from an alert? You mean you are getting a user response inside a alert delegate method and then you are creating one more alert. Am I right? – TeaCupApp Jun 15 '12 at 05:52
  • 1
    `wait_fences` has nothing to do with this crash. It looks like you're doing some `if ([err isEqualToString:@"someTest..."])...` - there's the problem. – Rok Jarc Jun 15 '12 at 06:00
  • There is nothing special about this NSString, so I not post it out. I print this NSString out using NSLog, so it isn't a nil. and here is the initialize code: NSString *inMessage = [userInfo objectForKey:@"NSUnderlyingError"]; NSLog(@"The error is: %@", inMessage); – kevin young Jun 15 '12 at 06:12
  • about alart from alart: I call the second's alart in the first alart's delegete : - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex – kevin young Jun 15 '12 at 06:15

1 Answers1

1

As others have pointed out in the comments, the issue here is that you have an NSError that is being treated mistakenly as an NSString.

inMessage seems to be your NSError object. This slips through the type system at compile time because userInfo has no knowledge of the types of its elements.

To fix this, you probably want to get the description of the error message and display that instead with something like

NSString *inMessage = [[userInfo objectForKey:@"NSUnderlyingError"] localizedDescription];
cobbal
  • 69,903
  • 20
  • 143
  • 156
  • yes, you are correct. it doesn't crash now. but it shows :wait_fences: failed to receive reply: 10004003 – kevin young Jun 15 '12 at 06:39
  • @kevinyoung I believe that http://stackoverflow.com/questions/4241894 might help with that. It seems there are a few things that could cause that message. – cobbal Jun 15 '12 at 06:46
  • sorry, other code causes this "wait_fences: failed to receive reply: 10004003". Not the second alert. thank you ! – kevin young Jun 15 '12 at 08:05