I am new to basic data. Can someone help me provide the right steps / tutorial showing how to save images for master data and reuse them too. I can store the string data already, but my application crashes when I try to save the image. To save:
DataEvent *event = (DataEvent *)[NSEntityDescription insertNewObjectForEntityForName:@"DataEvent" inManagedObjectContext:managedObjectContext]; NSURL *url2 = [NSURL URLWithString:@"xxxxxxxxxxxxxxx SOME URL xxxxxxxxxxxx"]; NSData *data = [[NSData alloc] initWithContentsOfURL:url2]; imageSave=[[UIImage alloc]initWithData:data]; NSData * imageData = UIImageJPEGRepresentation(imageSave, 100.0); [event setValue:self.imageSave forKey:@"pictureData"];
Recovery:
DataEvent *event = (DataEvent *)[eventsArray objectAtIndex:indexPath.row]; UIImage *image = [UIImage imageWithData:[event valueForKey:@"pictureData"]]; UIImageView *imageViewMainBackGround = [[UIImageView alloc] CGRect rect3=CGRectMake(0,2,100.0,100.0); imageViewMainBackGround.frame = rect3; [cell.contentView addSubview:imageViewMainBackGround]; [imageViewMainBackGround release];
source share