
static voID *AVSEPlayerItemStatusContext = &AVSEPlayerItemStatusContext;static voID *AVSEPlayerLayerReadyFordisplay = &AVSEPlayerLayerReadyFordisplay;
考虑以下
static voID *AVSEPlayerItemStatusContext = nil;static voID *AVSEPlayerLayerReadyFordisplay = nil;
在上面的两行中,我可以看出那些是2个静态的voID / generic指针,带有一些奇特的名字.
现在回到这两行,我再次粘贴在这里,
static voID *AVSEPlayerItemStatusContext = &AVSEPlayerItemStatusContext;static voID *AVSEPlayerLayerReadyFordisplay = &AVSEPlayerLayerReadyFordisplay;
上面的意思是,2个静态voID / generic指针存储它自己的&为什么它需要在什么意义上?
我只需要很少的指导来学习这种编码模式.
等待知识.
static voID *foo = &foo;
只是一种在编译时创建唯一指针的方法.
在该“AVSimpleEditoriOS”示例项目中,这些指针稍后用作上下文参数
[self addobserver:self forKeyPath:@"player.currentItem.status" options:NSkeyvalueObservingOptionNew context:AVSEPlayerItemStatusContext];
和
[self addobserver:self forKeyPath:@"playerLayer.readyFordisplay" options:NSkeyvalueObservingOptionInitial | NSkeyvalueObservingOptionNew context:AVSEPlayerLayerReadyFordisplay];
context参数的实际值根本不重要,它只是一些独特的
传递给的值
- (voID)observeValueForKeyPath:(Nsstring *)keyPath ofObject:(ID)object change:(NSDictionary *)change context:(voID *)context{ if (context == AVSEPlayerItemStatusContext) { // Notification for @"player.currentItem.status" // ... } else if (context == AVSEPlayerLayerReadyFordisplay) { // Notification for @"playerLayer.readyFordisplay" // ... } else { // Something else,pass to superclass: [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; }} (或者,可以检查observeValueForKeyPath中的keyPath参数.)请参阅下面的@BavarIoUs’评论,了解为什么唯一的上下文指针通常比键路径字符串更受欢迎.
总结以上是内存溢出为你收集整理的ios – 示例代码中AVFoundation.Framework中的静态void指针全部内容,希望文章能够帮你解决ios – 示例代码中AVFoundation.Framework中的静态void指针所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)