关闭

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

455人阅读 评论(0) 收藏 举报
分类:

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 :)
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:252881次
    • 积分:5525
    • 等级:
    • 排名:第4776名
    • 原创:222篇
    • 转载:81篇
    • 译文:21篇
    • 评论:10条
    最新评论