【发布时间】: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