2012-10-04 3 views
0

uint 값 대신 CGPoint 값을 myValues ​​사전에 저장하려면 아래 예제 코드를 적용하고 싶습니다. 나는 CoreFoundation에서 유형과 작업, 그래서 여기에 도움을 필요로하는지 정말 익숙하지 않다 : S이 샘플 코드를 수정하는 데 도움이되도록

- (void)cacheBeginPointForTouches:(NSSet *)touches 
    { 

     CFMutableDictionaryRef myValues = CFDictionaryCreateMutable (
                 kCFAllocatorDefault, 
                 20, 
                 NULL, 
                 NULL 
                ); 



     if ([touches count] > 0) { 
      for (UITouch *touch in touches) { 
       CGPoint *point = (CGPoint *)CFDictionaryGetValue(myValues, touch); 
       if (point == NULL) { 
        point = (CGPoint *)malloc(sizeof(CGPoint)); 
        CFDictionarySetValue(myValues, touch, point); 
       } 
       *point = [touch locationInView:view.superview]; 
      } 
     } 
    } 

답변

0

그냥 unsigned int 모든 CGPoint 발생을 교환한다.

+0

하! 천재. 그것은 별표, 나는 그들 주위에 항상 편안하지 않다 :) 감사합니다 – anna

+0

@anna : 별표는 포인터를 참조하십시오. 이것은 도움이 될 수 있습니다 : http://boredzo.org/pointers이 목적을 위해, 나는 malloc'ked 버퍼 대신에 NSValue 객체를 사용할 것을 권장합니다. http://developer.apple.com/library/ios/documentation/UIKit/Reference/NSValue_UIKit_Additions/ –

관련 문제