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

转载 2015年07月10日 16:33:55

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

相关文章推荐

使用Objective-C的+(void)initialize初始化static变量

在《Objective C类方法load和initialize的区别》一文中,我介绍了Objective-C对待+(void)initialize和+(void)load两个方法在编译和执行时出现的不...

"Batch,Batch,Batch":What does it really mean?

记录阅读Nvidia文章《"Batch,Batch,Batch":What does it really mean?》的一些心得

How does @synchronized lock/unlock in Objective-C?

问题:Does @synchronized not use "lock" and "unlock" to achieve mutual exclusion? How does it dolock/un...

What does (Aborted) mean in HttpWatch?

What does (Aborted) mean in HttpWatch?The result column in HttpWatch may sometimes display the value...

What is a meta-class in Objective-C?

In this post, I look at one of the stranger concepts in Objective-C — the meta-class. Every class in...

Objective-C categories in static library

转自:http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library 问: ...

how to use mp4box in objective-c

// //  ProcessingController.m //  VF-X264 // //  Created by John Paul Alcala on 10/30/10...

The elephant on the doorstep: What Wal-Mart’s arrival will mean to D.C.

The elephant on the doorstep: What Wal-Mart’s arrival will mean to D.C.By Jonathan O'Connell, Sunday...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)