2013-05-31 2 views
0

거짓말하지 않으려 고합니다. 책에서 자습서를 따르려고하고 있는데,이 경고를 지나칠 수 없습니다.'CGContextRef *'를 초기화하는 호환되지 않는 포인터 유형

Incompatible pointer types initializing 'CGContextRef *' (aka 'struct CGContext **') with an expression of type 'CGContextRef' (aka 'struct CGContext *')

기분을 상하게하는 라인은 다음과 같습니다 CGContextRef *imageContext = UIGraphicsGetCurrentContext();

- (IBAction)hide:(id)sender { 
    CGContextRef *imageContext = UIGraphicsGetCurrentContext(); 
    if (_myIcon.alpha == 1) { 
     [UIView beginAnimations:nil context:imageContext]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
     [UIView setAnimationDuration:3]; 
     [UIView setAnimationDelegate:self]; 
     _myIcon.alpha = 0.0; 
     [_hideButton setTitle:@"Show" forState:UIControlStateNormal]; 
    } else if (_myIcon.alpha == 0.0) { 
     [UIView beginAnimations:nil context:imageContext]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
     [UIView setAnimationDuration:3]; 
     [UIView setAnimationDelegate:self]; 
     _myIcon.alpha = 1; 
     [_hideButton setTitle:@"Hide" forState:UIControlStateNormal]; 
    } 

    [UIView commitAnimations]; 

} 
+0

현재 - 새로운 책이 필요합니다. 'UIView beginAnimations : context :'와'UIView commitAnimations'의 사용은 권장하지 않습니다. UIView의 새로운 블록 기반 애니메이션 메소드를 사용하는 것이 훨씬 낫습니다. – rmaddy

+0

@rmaddy 저작권 2013 ... 그 짜증. – nipponese

답변

0

CGContextRef 클래스가 아닙니다. 포인터가 필요하지 않습니다. 이 변경 :

CGContextRef *imageContext = UIGraphicsGetCurrentContext(); 

에 다음 UIGraphicsGetCurrentContext 기능에 대한 문서에서

CGContextRef imageContext = UIGraphicsGetCurrentContext(); 

봐. 반환 유형은 CGContextRef이며 CGContextRef *이 아닙니다.

+0

고맙습니다.이 책의 오타입니다. – nipponese

+0

책의 웹 사이트를보십시오. 일반적으로 실수를 지적하는 에라타 섹션이 있습니다. – rmaddy