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]};
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top