i am getting web data from .net web server using NSMutableUrl request.
i am getting the data using soap request after getting i am storing in NSDirectory by parsing response using NSXmlparsing.
my code is
NSArray *keys = [NSArray arrayWithObjects:@"id", @"firstname", @"lastname",@"addr",@"state",@"country",@"email",@"phone", nil];
directory = [NSDictionary dictionaryWithObjects:resultData forKeys:keys];
[[NSUserDefaults standardUserDefaults] setObject:directory forKey:@"dictionaryKey"];
It works fine but when ever if i enter wrong it gets exception like this.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSPlaceholderDictionary initWithObjects:forKeys:]: number of objects (0) not equal to number of keys (8)'
i am getting response from web server like this
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GenericAndroidMethodResponse xmlns="Mortgage"><GenericAndroidMethodResult><NewDataSet /></GenericAndroidMethodResult></GenericAndroidMethodResponse></soap:Body></soap:Envelope>
And application quits.
But if i got wrong response how can i recognize,at that time i need to display an alert but not quit from application.
how can i done this.
I think my question is clear.
can any one pls help me.
Thank u in advance.
You are trying to create a dictionary and pass it 8 keys (your
keysvariable), but you are not passing an equal number of values. In fact, Cocoa says yourresultDatais an empty array (or maybe even nil). So you need to protect your code with something like: