0

以下に示すように場所を見つけて設定しようとしていますが、「Invalid Initializer」というエラーが表示され続けます

CLLocationCoordinate2D location =[self.mapView addressLocation];

addressLocation メソッドは以下のとおりです

-(CLLocationCoordinate2D) addressLocation {
    NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
                       [searchBar.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    //NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
    NSError* error;
    NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];
    NSArray *listItems = [locationString componentsSeparatedByString:@","];

    double latitude = 0.0;
    double longitude = 0.0;

    if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {
        latitude = [[listItems objectAtIndex:2] doubleValue];
        longitude = [[listItems objectAtIndex:3] doubleValue];
    }
    else {
        //Show error
    }
    CLLocationCoordinate2D location;
    location.latitude = latitude;
    location.longitude = longitude;

    return location;
}

「無効な初期化子」エラーが発生する理由を教えていただけますか? 既にコアロケーション ロケーション フレームワークをインポートし、ヘッダー ファイルもインポートしました。何が間違っているのかわかりません。

4

1 に答える 1

2

を呼び出して[self.mapView addressLocation]います。そうではない[self addressLocation]でしょうか?私はあなたのクラスにあり、メソッドを持っていないと推測しmapViewMKMapViewいますaddressLocation

于 2011-05-09T03:36:54.773 に答える