【问题标题】:Please help to adapt this sample code请帮助调整此示例代码
【发布时间】:2012-10-04 23:16:24
【问题描述】:

我想修改下面的示例代码以在 myValues 字典中存储 uint 值而不是 CGPoint 值。我不太熟悉如何使用 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];
            }
        }
    }

【问题讨论】:

    标签: ios core-foundation cfmutabledictionary


    【解决方案1】:

    只需将所有出现的CGPoint 交换为unsigned int

    【讨论】:

    猜你喜欢
    • 2011-03-03
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 2021-05-05
    • 2014-10-31
    • 2013-12-22
    • 2010-11-04
    • 1970-01-01
    相关资源
    最近更新 更多