IOS Code


Code for .h file

ViewController.h

#import 


@interface ViewController : UIViewController

@property (strong, nonatomic) IBOutlet UITableView *TableView;

@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *vinicity;
@property (strong, nonatomic) NSString *lat;
@property (strong, nonatomic) NSString *lng;
@property (strong, nonatomic) NSMutableArray *dataarray;
-(void)FetchData;

@end


===================

Code for .m file

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.dataarray = [[NSMutableArray alloc]init];
    [self FetchData];
    
}
- (id)initWithname:(NSString *)name vinicity:(NSString *)vinicity lat:(NSString *)lat lng:(NSString*)lng{
    if ((self = [super init])) {
        
        self.name = name;
        self.vinicity = vinicity;
        self.lat = lat;
        self.lng = lng;
    }
    return self;
}

-(void)FetchData;
{
    
    
    NSString *googleURL = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/
place/nearbysearch/json?location=-33.8670,151.1957&radius=500&types=food&name=
cruise&key=AIzaSyD7g423k39xJjr6UraNDN8s2XjnkQIbD-Y"];
    
    
    NSURL* apiUrl = [NSURL URLWithString:googleURL];
    
    NSError *error;
    NSString *apiResponse = [NSString stringWithContentsOfURL:apiUrl encoding:NSUTF8StringEncoding error:&error];
    
    
    NSData *responseData = [apiResponse dataUsingEncoding:NSUTF8StringEncoding];
    
    
    NSError* error1;
    NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error1];
    
    NSArray *ResultArray  = [json objectForKey:@"results"];
    
    for (int i=0; i