을 작동하지 않는 코드는 ADRESS 검색을 수행해야한다. CLLocationCoordinate2D location2 = [self adressLocation
가 작동하지 않는 라인을. 그것은 잘못 될 수 무엇 "잘못된 이니셜."말하는?이유는 "CLLocationCoordinate2D LOCATION2 = [자기 adressLocation는"
-(IBAction) search {
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 0.4;
span.longitudeDelta = 0.4;
CLLocationCoordinate2D location2 = [self adressLocation];
region.span = span;
region.center = location2;
Mark adr = [[Mark alloc] initWithCoordinate:location2];
[mapView addAnnotation:adr];
}
-(CLLocationCoordinate2D) adressLocation {
NSString * urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",[suchFeld.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString * locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSUTF8StringEncoding error:&fileError];
NSArray * listItems = [locationString componentsSeparatedByString:@","];
double latitude2 = 0.0;
double longitude2 = 0.0;
if ([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"])
{
latitude2 = [[listItems objectAtIndex:2] doubleValue];
longitude2 = [[listItems objectAtIndex:3] doubleValue];
} else {
// error
CLLocationCoordinate2D location2;
location2.latitude = latitude2;
location2.longitude = longitude2;
return location2;
}
.h에 추가하는 대신 파일 맨 위에있는 클래스 확장에서이를 선언 할 수 있습니다. 이것은 메소드의 "private"특성을 보존하면서 선언합니다. –
@ 케빈 발라드 : 좋은 지적, 고마워. – Anna