Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 如何唯一标识cgcontext?_Cocoa_Macos_Core Graphics_Quartz Graphics - Fatal编程技术网

Cocoa 如何唯一标识cgcontext?

Cocoa 如何唯一标识cgcontext?,cocoa,macos,core-graphics,quartz-graphics,Cocoa,Macos,Core Graphics,Quartz Graphics,是否有任何方法可以唯一标识CGContextRef 谢谢ACGContextRef只是指向CGContext结构的指针。因为它是一个指针,所以您可以使用相等来检查它们是否是相同的上下文: if( context1 == context2 ) { //the contexts are the same } 如果需要跟踪特定的上下文,只需将对它们的引用存储在ivar或其他变量中。然后,可以使用相等来检查上下文是否匹配: if( someContext == yourContextIvar

是否有任何方法可以唯一标识CGContextRef


谢谢A
CGContextRef
只是指向
CGContext
结构的指针。因为它是一个指针,所以您可以使用相等来检查它们是否是相同的上下文:

if( context1 == context2 )
{
    //the contexts are the same
}
如果需要跟踪特定的上下文,只需将对它们的引用存储在ivar或其他变量中。然后,可以使用相等来检查上下文是否匹配:

if( someContext == yourContextIvar )
{
    //the contexts are the same
}

“唯一标识”是什么意思?我正在寻找CGContextRef的某种标识符,它可以帮助区分两种不同的上下文。Robs的答案似乎就是您要寻找的。你可以接受它作为正确答案。我已经在使用参考技术了。我实际上是在为这个寻找某种API。无论如何,谢谢。它不需要API,因为它是基本的C语言。