문제

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