iPhone和模拟器上存在EXC_BAD_ACCESS问题
|
我在自己的代码之外得到了EXC_BAD_ACCESS。目前,我的代码通过shareURLCache对象获取一个URL,然后启动url连接。离开启动URL连接的方法后,我点击了EXC_BAD_ACCESS。我尝试使用仪器查找任何僵尸,并且分析了内存泄漏,但都没有出现。在这一点上,我完全陷入困境。
这是加载网址并启动网址连接的代码
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@\"At new location: %@\",newLocation);
MKCoordinateRegion region =
MKCoordinateRegionMakeWithDistance([newLocation coordinate], 750, 750);
[mapView setRegion:region animated:YES];
[location stopUpdatingLocation];
CLLocationCoordinate2D coord = [newLocation coordinate];
NSURL *url = [urlCache getReccomendationForUID:@\"12345\" atLat:coord.latitude
atLon:coord.longitude forCategories:nil];
// Create the request.
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
if (connection) {
// Create the NSMutableData to hold the received data.
// xmlData is an instance variable declared elsewhere.
xmlData = [[NSMutableData alloc]init];
} else {
NSLog(@\"Could not create connection\");
}
}
来自sharedURLCache的方法,该方法返回url
-(NSURL *)getReccomendationForUID:(NSString *)u atLat:(double)lat atLon:(double)lon forCategories:(NSArray *)cat
{
if(remote) {
NSMutableString *categories = [[NSMutableString alloc]init];
for(NSString *s in cat) {
[categories appendString:@\"&cat=\"];
[categories appendString:s];
}
NSString *s = [NSString stringWithFormat:@\"%@/recommendation?uid=%@&psw=null&lat=%f&lon=%f?%@\",
apiRoot,u,lat,lon,categories];
[categories release];
return [NSURL URLWithString:s];
} else {
return [[NSBundle mainBundle] URLForResource:@\"XMLTest\" withExtension:@\"xml\"];;
}
}
没有找到相关结果
已邀请:
2 个回复
抵浮细
仇聘发栖
此方法不喜欢快速更新...