10
我试图使用CGPathApply遍历CGPathRef对象中的每个CGPathElement(主要是编写一种自定义方式来保存CGPath数据)。问题是,每次它调用CGPathApply时,我的程序崩溃都没有任何信息。我怀疑这个问题存在于applier函数中,但我无法说清楚。这里是我的代码示例:如何正确使用CGPathApply
- (IBAction) processPath:(id)sender {
NSMutableArray *pathElements = [NSMutableArray arrayWithCapacity:1];
// This contains an array of paths, drawn to this current view
CFMutableArrayRef existingPaths = displayingView.pathArray;
CFIndex pathCount = CFArrayGetCount(existingPaths);
for(int i=0; i < pathCount; i++) {
CGMutablePathRef pRef = (CGMutablePathRef) CFArrayGetValueAtIndex(existingPaths, i);
CGPathApply(pRef, pathElements, processPathElement);
}
}
void processPathElement(void* info, const CGPathElement* element) {
NSLog(@"Type: %@ || Point: %@", element->type, element->points);
}
任何想法,为什么调用此方法施加似乎要崩溃?任何帮助是极大的赞赏。
http://www.mlsite.net/blog/?p=1312 – 2011-02-26 00:37:55
看看这里,这是一篇关于如何正确使用CGPathApply的好帖子:http://oleb.net/blog/2012/12 /访问-漂亮印刷-cgpath元素/ – 2013-12-20 08:06:10