i am getting exception over these lines of code dont know why its giving so ..Help me out ..
reason is:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSArrayI floatValue]: unrecognized selector sent to instance 0x7c57840'
coord.latitude = [[[self.holdingArray objectAtIndex:k]
valueForKey:@"latitude"]floatValue];
coord.longitude = [[[self.holdingArray objectAtIndex:k] valueForKey:@"longitude"]
floatValue];
Edit 1
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[appDelegate.dealerDataGlobalArray removeAllObjects];
NSString *requestString;
requestString = [NSString stringWithFormat:@"http://www.hvinfotech.net/projects/carwash
/search.php?search=%@",textField.text];
NSString *strCOntents1 = [NSString stringWithContentsOfURL:[NSURL
URLWithString:requestString] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"Data: %@",strCOntents1);
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL
URLWithString:requestString]];
DealerDetailParser *parser = [[DealerDetailParser alloc]
initDealerDetailParserXMLParser];
[xmlParser setDelegate:parser];
[xmlParser parse];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
NSLog(@"dealerDataGlobalArray...... %@",[appDelegate.dealerDataGlobalArray
description]);
[holdingArray addObject:appDelegate.dealerDataGlobalArray];
NSLog(@"holdingArray...... %@",holdingArray);
flagForHoldingArray = YES;
[self loadOurAnnotations];
[textField resignFirstResponder];
return YES;
}
i have edited so that it can be more clear. I am calling the webservice to get the data corresponding to what is entered in text field. After that i call the method in which previous line o code were posted…
Edit2
it gives like
2012-01-23 00:27:35.475 CarWashApp[2584:11603] (
{
businessdesc = "having a garage and teamof 10members, originaly belongs to mumbai
maharashtra.";
"businessdesc_de" = "having a garage and teamof 10members, originaly belongs to
mumbai maharashtra.";
city = vadodra;
"city_de" = "dadar_de";
companyname = "Maruti Suzki Ltd";
"companyname_de" = "Maruti Suzki Ltd _de";
contactname = "bijju sharma";
"contactname_de" = "bijju sharma_de";
coupondetails = "10% Discount";
"coupondetails_de" = "10% Discount _de";
email = "bsharma@gmail.com";
friday = "Friday: Closed";
happyhour = "10:00 AM to 5:00 PM";
id = 5;
latitude = "22.30731";
logo = "http://www.hvinfotech.net/projects/carwash/upload/images/Sunset.jpg";
longitude = "73.181098";
monday = "Monday: Closed";
payment = Visa;
payments = "";
phone1 = 07932453453;
phone2 = 07934344444;
postcode = JU113;
saturday = "Saturday:9:30 AM - 4:00 PM";
services = "";
state = Groningen;
"state_de" = Groningen;
streetaddress1 = "500 golf Road,";
"streetaddress1_de" = "sectore 5 d_de";
streetaddress2 = "airport Road";
"streetaddress2_de" = "";
sunday = "Sunday:9:30 AM - 4:00 PM";
thursday = "Thursday: Closed";
tuesday = "Tuesday:9:30 AM - 4:00 PM";
website = "http://hvinfotechPvtLtd.com";
wednesday = "Wednesday: Closed";
}
)
2012-01-23 00:27:43.434 CarWashApp[2584:11603] (
"22.30731"
)
i need only above value i.e “22.30731” as coordinate but its showing error if i also write like
coord.latitude = [[self.holdingArray objectAtIndex:k] valueForKey:@”latitude”];
As @Rayfleck said, the object in the array might be not be the kind of object you’re expecting it to be. Use the debugger or
NSLog()to find out what object it actually is.Another possibility, is you might have a memory management bug somewhere. Do you have ARC enabled?
And finally, it could be a thread safety issue. In that case, best of luck finding it! There isn’t really any easy way to track down threading issues, except read every line of code and try to find the mistake.
EDIT:
You have this line of code:
It looks like you are adding an array object to the
holdingArrayarray. Array objects will return another array when you sendvalueForKey:to them (lookup valueForKey in the documentation for NSArray…).Anyway, the array object doesn’t respond to
floatValue. OnlyNSStringandNSNumberobjects respond tofloatValue.You should
NSLog()these objects, because I think they are not what you expect them to be: