I'm implementing Auto Enhancing in my app. My code goes like this:
CIImage *toBeEnhancedImage = [CIImage imageWithCGImage:_originalImage.CGImage];
NSDictionary *options = @{CIDetectorImageOrientation : [[toBeEnhancedImage properties] valueForKey:kCGImagePropertyOrientation]};
NSArray *adjustments = [toBeEnhancedImage autoAdjustmentFiltersWithOptions:options];
Before Running the code, I get the following error next to NSDictionary:
Incompatible pointer types sending 'const CFStringRef (AKA 'const struct__CFString const)to parameter of type NSString*
When i run the code, it crashes. I know what the error means but the code is actually taken from Apple's documentation and it doesn't work! is there a workaround?
You should type cast your CFStringRef variable to NSString *. Change the second line of your code with below lines:
NSDictionary *options = nil;
if([[toBeEnhancedImage properties] valueForKey:(NSString *)kCGImagePropertyOrientation] == nil)
{
options = @{CIDetectorImageOrientation : [NSNumber numberWithInt:1]};
}
else
{
options = @{CIDetectorImageOrientation : [[toBeEnhancedImage properties] valueForKey:(NSString *)kCGImagePropertyOrientation]};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With