Reputation: 1341
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?
Upvotes: 3
Views: 2139
Reputation: 17186
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]};
}
Upvotes: 6