Why is my app crashing when I allocate NSError userInfo to set a NSDictionary?

Go To StackoverFlow.com

0

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"Please, other format selected.", NSLocalizedDescriptionKey, @"This format is not available.", NSLocalizedFailureReasonErrorKey, @"The operation couldn't be completed.", NSUnderlyingErrorKey, self.URL, NSURLErrorKey, nil];

NSLog(@"dict:%@", dict); // no Crash

NSError *error = [NSError errorWithDomain:@"testError" code:1 userInfo:dict];// crash

why crashing when allocate error object?


Here are the crash details:

+[__NSCFConstantString objectForKey:]: unrecognized selector sent to class 0x3ebf5550
2012-04-05 01:21
by bitmapdata.com


3

IIRC NSUnderlyingErrorKey is supposed to be another instance of NSError.

From the docs:

The user info dictionary can sometimes include another NSError object that represents an error in a subsystem underlying the error represented by the containing NSError. You can query this underlying error object to obtain more specific information about the cause of the error.

You access the underlying error object by using the NSUnderlyingErrorKey dictionary key.

2012-04-05 01:46
by Wevah
sincerely, Thanks for your kindly answer - bitmapdata.com 2012-04-05 01:51
Ads