- Registriert
- 05.05.14
- Beiträge
- 2
Moinsen,
da ich hier "der neue" bin stelle ich mich kurz vor.
Ich 22 komme aus HH und arbeite als App Programmierer.
Nun bin ich jedoch an einem Punkt angelangt, wo ich nicht mehr weiter weiß.
Unzwar bekomme ich, wenn ich ein Wert aus einer JSON Datei ausgeben möchte immer eine Klammer "(" zurück.
Hier mal die Snippets:
So sieht der Output in der Konsole aus
Und folgendes für die Ausgabe in einem Label:
Ich habe iwie das Gefühl, dass es an dem Array liegt. Aber mit NSDictionary bekomme ich das gleiche.
Vielen Dank im Voraus.
da ich hier "der neue" bin stelle ich mich kurz vor.
Ich 22 komme aus HH und arbeite als App Programmierer.
Nun bin ich jedoch an einem Punkt angelangt, wo ich nicht mehr weiter weiß.
Unzwar bekomme ich, wenn ich ein Wert aus einer JSON Datei ausgeben möchte immer eine Klammer "(" zurück.
Hier mal die Snippets:
Code:
-(void)getJSON
{
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:LNY_URL]];
NSError *error = nil;
NSArray *result = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
_sightNames = [result valueForKeyPath:@"spots"];
NSLog(@"%@",_sightNames[0]);
[self.tableView reloadData];
}
So sieht der Output in der Konsole aus
Code:
2014-05-05 13:36:19.520 lovingnewyork[2848:60b] (
{
passes = "cp nyp nypb ex";
prices = {
adult = 27;
child = 21;
};
spotId = "top-poi-1";
spotName = "Empire State Building - Aussichtsplattform";
},
{
passes = "cp nyp nypb ex";
prices = {
adult = 27;
child = 17;
};
spotId = "top-poi-2,exception-1,cp";
spotName = "Aussichtsplattform Top of the Rock";
},
{
passes = "nyp nypb ex";
prices = {
adult = 22;
child = 7;
};
spotId = "top-poi-3";
spotName = "9/11 Tribute Center";
},
{
passes = nypb;
prices = {
adult = 161;
child = 121;
};
spotId = "top-poi-4,exception-3,nybp";
spotName = "Hop-On-Hop-Off-Tour (Flexibel: Uptown, Downtown, Harlem UND Night Tour)";
},
{
passes = "nypb ex";
prices = {
adult = 44;
child = 34;
};
spotId = "top-poi-5,exception-3,nybp";
spotName = "Hop-On-Hop-Off-Tour (Nur Downtown)";
},
{
passes = "nyp nypb";
prices = {
adult = 35;
child = 28;
};
spotId = "top-poi-6";
spotName = "Brooklyn Bridge und DUMBO-Spaziergang";
}
)
Und folgendes für die Ausgabe in einem Label:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"sightTableCell";
SightSeeingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
cell.sightLabel.text = [NSString stringWithFormat:@"%@",[_sightNames valueForKey:@"spotName"]];
return cell;
}
Ich habe iwie das Gefühl, dass es an dem Array liegt. Aber mit NSDictionary bekomme ich das gleiche.
Vielen Dank im Voraus.