0
목표는 JSON으로 iphone에 sqlbinary를 보내는 웹 서비스를 통해 SQL Server에서 varbinary로 저장된 이미지를 가져 오는 것입니다. JSON에서 보낸 base64binary에서 UIImage를 설정하는 데 문제가 있습니다. NSData로 바이너리를 변환 할 수 있지만 이미지가 데이터를 통해 설정되지 않습니다.UIImage가 NSData에서 설정되지 않음
for (int i = 0; i < array.count; i++) {
NSDictionary *mealInfo = [array objectAtIndex:i];
Meal *meal =[[Meal alloc]initWithRestaurant:[mealInfo objectForKey:@"restaurantname"]
mealName:[mealInfo objectForKey:@"itemname"]
description:[mealInfo objectForKey:@"itemdescription"]
Time:[mealInfo objectForKey:@"mealTime"]
price:[mealInfo objectForKey:@"itemprice"]];
//NSString *str = @"data:image/jpg;base64,";
//str = [str stringByAppendingString:[mealInfo objectForKey:@"itemImage"]];
//NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
NSString *str = [mealInfo objectForKey:@"itemImage"];
NSLog(@"%@", str);
NSData *d = [[NSData alloc]initWithData:[NSData dataFromBase64String:str]];
UIImage *image = [UIImage imageWithData:d];
[meal setMealImage:image];
[meals addObject:meal];
}
NSLog(@"%@",[[meals objectAtIndex:0]mealPrice]);
NSLog(@"This is how many meals %d", meals.count);