Google 搜索地点 API 只找到 2 个地点?

Google search places API getting only 2 places?

我使用下面的代码搜索地点并获取我在下面使用的地点列表 api (https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=%@&key=My_Key)。它工作正常,但在每次搜索中只显示两个位置。但是 GMSAutoCompleteViewController 为每次搜索显示了两个以上的位置。如何为 GMSAutoCompleteVC 等每次搜索获取两个以上的位置。

#import "ViewController.h"
#import <GooglePlaces/GooglePlaces.h>

@interface ViewController () <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource> {

    NSMutableArray *searchArray;
    NSString *strSearch;

}

@property (weak, nonatomic) IBOutlet UITextField *searchTextfeild;
@property (weak, nonatomic) IBOutlet UITableView *tbl_vw1;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.  

    _searchTextfeild.delegate = self;
    _tbl_vw1.delegate = self;
    _tbl_vw1.dataSource = self;
    _tbl_vw1.hidden = YES;

    _searchTextfeild.clearButtonMode = UITextFieldViewModeAlways;

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)LoadJson_search{

    searchArray=[[NSMutableArray alloc]init];
    //    NSLog(@"str......%@",strSearch);
    // This API key is from https://developers.google.com/maps/web/
    NSString *str1 = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=%@&key= My_Key", strSearch];
    NSURL *url = [NSURL URLWithString:str1];

    NSData *data = [NSData dataWithContentsOfURL:url];
    NSError *error=nil;
    if(data.length==0)
    {

    }
    else
    {
        NSDictionary *jsondic= [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

        //         NSLog(@"1,,,,%@",jsondic);
        [searchArray removeAllObjects];
        if([[jsondic objectForKey:@"status"]isEqualToString:@"ZERO_RESULTS"])
        {

        }
        else if([[jsondic objectForKey:@"status"]isEqualToString:@"INVALID_REQUEST"])
        {
        }
        else
        {
        for(int i=0;i<[jsondic.allKeys count];i++)
        {
            NSString *str1=[[[jsondic objectForKey:@"predictions"] objectAtIndex:i] objectForKey:@"description"];
            [searchArray  addObject:str1];
        }
        _tbl_vw1.hidden = NO;
       //            NSLog(@"%@", searchArray);
        }
    if (searchArray.count == 0) {
        _tbl_vw1.hidden = YES;
    }else{
        [_tbl_vw1 reloadData];
    }
}
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;{
    if (textField.tag == 3) {
        strSearch = [textField.text stringByReplacingCharactersInRange:range withString:string];
         if([string isEqualToString:@" "]){

         }else{
             [self LoadJson_search];
         }
    }
    return YES;
}


- (BOOL)textFieldShouldClear:(UITextField *)textField{
    _tbl_vw1.hidden = YES;
     [_tbl_vw1 reloadData];

    return YES;
}


//TableView delegates
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return searchArray.count;
}


-(UITableViewCell *)tableView:(UITableView*)aTableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {

    UITableViewCell *cell = [_tbl_vw1 dequeueReusableCellWithIdentifier:@"cell"];
    if(!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    //    NSLog(@"searchArray ==== %@", searchArray);
    cell.textLabel.text = [searchArray objectAtIndex:indexPath.row];

    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    _searchTextfeild.text = [searchArray objectAtIndex:indexPath.row];

    _tbl_vw1.hidden = YES;
    [_tbl_vw1 reloadData];

}

我这样修改了我的代码...

我得到了两个以上的名额,但我用了 json count [jsondic.allKeys count]

for(int i=0;i<[jsondic.allKeys count];i++)
    {
        NSString *str1=[[[jsondic objectForKey:@"predictions"] objectAtIndex:i] objectForKey:@"description"];
        [searchArray  addObject:str1];
    }

现在我只有两个名额

现在我将 json count 从 [jsondic.allKeys count] 更改为 [[jsondic objectForKey:@"predictions"] count]

for(int i=0;i<[[jsondic objectForKey:@"predictions"] count];i++)
    {
        NSString *str1=[[[jsondic objectForKey:@"predictions"] objectAtIndex:i] objectForKey:@"description"];
            [searchArray  addObject:str1];
    }

现在我得到了两个以上的名额.....