【发布时间】:2012-08-14 13:11:59
【问题描述】:
我有这个代码只能获取半径 10 公里内的咖啡馆:
for (NSString *ndlog in log) {
NSString *name = [names objectAtIndex:i];
NSString *city = [citys objectAtIndex:i];
NSString *chain = [chains objectAtIndex:i];
NSString *street = [streets objectAtIndex:i];
NSString *ndlig = [lig objectAtIndex:i];
dlog = [ndlog doubleValue];
dlig = [ndlig doubleValue];
NSLog(@"%@,%@,%@,%@,%f,%f,%@,%@", name, city, chain, street, dlog, dlig, ndlog, ndlig);
CLLocation *location = [[CLLocation alloc] initWithLatitude:dlog longitude:dlig];
double meters = [userLocation distanceFromLocation:location];
if (meters < 10000) {
NSString *data = [NSString stringWithFormat:@"%@,%@,%@,%@", name, city, chain, street];
[tableData addObject:data];
}
i++;
}
它在 iOS 模拟器上运行,但在 iPhone 2G 上崩溃。 (iOS 3.1.3)
我的代码中有什么不正确的地方?
【问题讨论】:
标签: iphone objective-c ios ios-3.x