2016-04-15 8 views
0
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 


    NSURL *url=[NSURL URLWithString:@"http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo"]; 
    NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url]; 
    [[NSURLConnection alloc]initWithRequest:request delegate:self]; 

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ 

    _data=[[NSMutableData alloc]init]; 
} 

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)thedata{ 

    [_data appendData:thedata]; 



-(void)connectionDidFinshLoading:(NSURLConnection *)connection{ 

    _name=[NSJSONSerialization JSONObjectWithData:_data options:NSJSONReadingMutableContainers error:nil]; 
     [self.tableView reloadData]; 
+1

benötigen weitere Informationen. was lädt nicht? ist die UI-Anzeige? leere Tabelle? irgendwelche Fehlermeldungen? –

+0

Plesae verwenden grundlegende Formatierungsoptionen – Daenarys

Antwort

0

{ "geonames": [{ "lng": - 99,12766456604, "geonameId": 3.530.597, "country": "MX", "name": "Mexiko -Stadt ", " fclName ":" Stadt, Dorf, ... ", " toponymName ":" Mexiko-Stadt ", " fcodeName ":" Hauptstadt einer politischen Einheit ", " wikipedia ":" en. wikipedia.org/wiki/Mexico_City“, "lat": 19,428472427036, "fcl": "P", "Population": 12.294.193, "fcode": "PPLC" }, { "lng": 116,397228240967 , "geonameId": 1.816.670, "Länderkennung": "CN", "name": "Peking", "fclName": "Stadt, Dorf, ...", "toponymName": "Beijing", "fcodeName": "Hauptstadt einer politischen Einheit", "wikipedia": "en.wikipedia.org/wiki/Beijing", "lat": 39.9074977414405, "fcl": "P", "Bevölkerung": 11716620 , "fcode": "PPLC" }]}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    return [self.name count]; 
} 

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

UITableViewCell *cell = 
       [tableView dequeueReusableCellWithIdentifier:@"Cell" 
          forIndexPath:indexPath]; 

    // Configure the cell... 
    cell.textLabel.text=[[self.nameobjectAtIndex:indexPath.row]objectForKey:@"geonameId"]; 

    return cell; 
} 

sein keine Fehlermeldung zeigt ..... seinen Lauf ...... und die leere Tabellenansicht zeigt .....

Verwandte Themen