Please solve my issue it giving me error as
-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x6891460
NSString *urlString = @"http://192.168.1.190:8080/mwharf/retrive.action?action=consigneeName&startConsgn=";
NSString *url = [urlString stringByAppendingString:txtConsignee.text];
NSData *webData=[NSMutableData dataWithContentsOfURL:[NSURL URLWithString:url]];
NSArray *jsonDict=[NSJSONSerialization JSONObjectWithData:webData options:kNilOptions error:&error];
NSMutableArray *tempArray;
NSMutableArray *consigneeArray=[[NSMutableArray alloc]init];
NSInteger arrayCount=0;
for (int i=0; i<[jsonDict count]; i++) {
consigneeArray =[jsonDict objectAtIndex:i];
NSLog(@"consigneeArray :%@",consigneeArray);
tempArray=[[NSMutableArray alloc]initWithArray:[consigneeArray objectAtIndex:arrayCount]];
[consigneeArray insertObject:tempArray atIndex:arrayCount];
arrayCount++;
}
NSArray *passArray=[NSArray arrayWithObject:consigneeArray];
NSLog(@"passArray :%@",passArray);
[NSJSONSerialization JSONObjectWithData:] returns a NSDictionary and not NSArray. So because NSDictionary has no such method objectAtIndex you’ve got an error. Try this:
However return type could also be NSArray or NSString, it depends on your JSON structure. So the best way is to check the return type using
etc.
and parse each return type respectively