iphone - 将浮点值从数组传递到坐标时出现异常

标签 iphone ios

我在这些代码行中遇到异常不知道为什么它给出如此..帮助我.. 原因是:

*** 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];

编辑 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;
}

我已经编辑了,这样可以更清楚。我正在调用网络服务以获取与文本字段中输入的内容相对应的数据。之后我调用了发布前一行代码的方法...

编辑2

它给了我

    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"
)

我只需要上面的值,即“22.30731”作为坐标,但如果我也这样写,它会显示错误 coord.latitude = [[self.holdingArray objectAtIndex:k] valueForKey:@"latitude"];

最佳答案

self.holdingArray 中有哪些对象 - 字典? 好的,字典中的键“经度”是什么样的对象?看起来它们是数组。 拆分这些类型的嵌套语句通常是一种很好的做法,这样您就可以轻松进行调试。

关于iphone - 将浮点值从数组传递到坐标时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8963284/

相关文章:

ios - 是否可以像谷歌地图一样使用第 3 方 reactjs 组件和 react-native?

ios - 从 UIView 动画中获取 UIImage

ios - NSString 字符串与 CString :encoding: - not copying the Cstring?

ios - 将外部字体导入 iPhone 应用程序

iphone - 如果我只支持 iPhone 4+,我还需要标准分辨率资源吗

iphone - UISearchDisplayController-如何禁用自动搜索

javascript - 钛合金主干及ACS

ios - 如果轻轻触摸,Force Touch 动画会卡住

iphone - 尝试从 iphone 连接到 node.js 和 socket.io 0.7.2

iphone - PhoneGap 2.9 中缺少 libCordova.a 文件