0

尝试在 objC 中使用 GMSPlacePicker 时,此错误导致应用程序崩溃

'NSInvalidArgumentException',原因:'*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:尝试从对象 [1] 中插入 nil 对象'

该应用程序当时崩溃了[placePicker pickPlaceWithCallback:^(GMSPlace * _Nullable place, NSError * _Nullable error)

整套代码块如下:

    CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(22.631514, 51.4723);
    CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(26.0765, 56.4395);
    GMSCoordinateBounds *viewport = [[GMSCoordinateBounds alloc] initWithCoordinate:northEast coordinate:southWest];
    GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:viewport];
    GMSPlacePicker *placePicker = [[GMSPlacePicker alloc] initWithConfig:config];
    [placePicker pickPlaceWithCallback:^(GMSPlace * _Nullable place, NSError * _Nullable error)
    {
        if (error!= NULL && error != nil) {
            NSLog(@"PlacePicker error: %@", [error localizedDescription]);  
            return;
        }
         if (place != NULL && place != nil) {
            NSLog(@"PlacePicker cordinates: (%f, %f)", place.coordinate.latitude, place.coordinate.longitude);
         } else {
            NSLog(@"No place selected");
         }
    }];

请帮忙。

4

0 回答 0