How to solve this EXC_BAD_ACCESS(code=EXC_i386_GPFLT )in swift programming

前端 未结 5 988
[愿得一人]
[愿得一人] 2020-12-10 18:40

this is my code.getting this EXC_BAD_ACCESS(code=EXC_i386_GPFLT).I don\'n know how to find and solve plz help me ...application getting crash when get longitude

5条回答
  •  悲&欢浪女
    2020-12-10 19:12

    This response you are getting :"http://maps.googleapis.com/maps/api/geocode/json?address=Hyderabad,india"

    You can fetch like below:

    Here jsondict is your respnse from api

    NSArray *results = [jsonDict objectForKey:@"results"];    
    NSDictionary *geometry = [[results objectAtIndex:0] valueForKey:@"geometry"];
    NSArray *location = [geometry objectForKey:@"location"];
    float lat = [[location valueForKey:@"lat"] floatValue];    
    float lng = [[location valueForKey:@"lng"] floatValue];
    

提交回复
热议问题