What does it mean to write `static void * ptr = &ptr` in objective-c?

What does it mean to write static void * ptr = &ptr in objective-c?

问题:

i am reading apple’s recently (dec 5, 2013) updated sample code for camera control using av foundation (here is the link). and i come across the following lines in the file avcamviewcontroller.m which i don’t understand.

static void * capturingstillimagecontext = &capturingstillimagecontext;static void * recordingcontext = &recordingcontext;static void * sessionrunninganddeviceauthorizedcontext = &sessionrunninganddeviceauthorizedcontext;

回答:

well, so idea for these constants is to have some unique value, that will not repeat anywhere in the program, but we don't really care about its content.

now, instead of coming up with some random string/number etc, we just create a pointer, and put its address as content, this way it's unique and the code is simple is nice :)
阅读更多
个人分类: C/C++
上一篇UIMenuController
下一篇NSLog输出
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭