NSjsonserialization sorunu
Merhabalar,
Nsjsonserialization kullanarak yaptim ama simulator label icinde herhangi bir data gelmiyor .Consol ekraninda api ciktisi aliyorum ama simulatorde data gelmiyor . nedeni ne olabilir
[code]
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *JSONFeed= [NSURL URLWithString:@"http://marsweather.ingenology.com/v1/latest/"];
NSError * error = nil;
NSData * JSONData =[NSData dataWithContentsOfURL:JSONFeed options:NSDataReadingUncached error:&error];
id jsonObject= [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:&error];
if (jsonObject !=nil && error==nil) {
NSLog(@"Success");
if ([jsonObject isKindOfClass:[NSDictionary class]]) {
NSDictionary * dics= (NSDictionary*)jsonObject; NSLog(@"disc JSON Dictionary =%@",dics);
for (NSString* dataType in dics) {
if ([dataType isEqualToString:@"json"]) {
NSDictionary * content = [dics objectForKey:dataType];
for (NSDictionary* data in content) {
NSDictionary * detailContent = [data objectForKey:@"report"];
NSString * date= [detailContent objectForKey:@"Terrestrial_date"];
//NSNumber * sola =[detailContent objectForKey:@"sol"];
//NSNumber * lss =[detailContent objectForKey:@"ls"];
//NSNumber * minTemp = [detailContent objectForKey:@"min_temp"];
//NSNumber * minTempFah= [detailContent objectForKey:@"min_temp_fahrenheit"];
//NSNumber * maxTemp =[detailContent objectForKey:@"max_temp"];
//NSNumber * maxTempFah =[detailContent objectForKey:@"max_temp_fahrenheit"];
NSString *atmo = [detailContent objectForKey:@"atmo_opacity"];
wweather.text=[NSString stringWithFormat:date,atmo];
}
}
}
}
else if ([jsonObject isKindOfClass:[NSArray class]]){
NSArray * arrray = (NSArray*)jsonObject;NSLog(@"JSon Array =%@",arrray);
}
}
else if (error !=nil){
NSLog(@"an error");
}
}
[/code]