I have an app where I save the current view as an image using the following code:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
savedImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Now I want to be able to post this image to Facebook. I have the following code:
if([SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook]) {
slComposeView = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[slComposeView addImage: [UIImage imageNamed:savedImg]];
[self presentViewController:slComposeView animated:YES completion:NULL];
}
Obviously this is wrong because I cannot pass UIImage to an NSString. What is the correct way to do it?
Get rid of the imageNamed call and pass the savedImg variable directly into the addImage call.