[英]How can I work with this value in a method - Objective C
I have to pass the following object to a method, have that method modify it so that after the method call I can move on with my modified object. 我必须将以下对象传递给一个方法,让该方法修改它,以便在方法调用后我可以继续使用我修改过的对象。
AVMutableCompositionTrack *compositionVideoTrack[2];
passing it like this currently: 像这样传递它:
[self buildShow:&compositionVideoTrack];
the buildshow method looks like this: buildshow方法如下所示:
-(void)buildShow:(AVMutableCompositionTrack**)videoTracks{
}
I am getting this compiler warning and it is not currently working: 我收到此编译器警告,它目前无法正常工作:
Incompatible pointer types sending 'AVMutableCompositionTrack *__strong (*)[2]' to parameter of type 'AVMutableCompositionTrack *__autoreleasing *' 不兼容的指针类型将'AVMutableCompositionTrack * __ strong(*)[2]'发送到'AVMutableCompositionTrack * __ autoreleasing *'类型的参数
How can I change this to make it work? 如何更改此功能以使其正常工作?
Just pass it like this: 就像这样传递它:
[self buildShow:compositionVideoTrack];
When you declare it like this: 当你声明它是这样的:
AVMutableCompositionTrack * __autoreleasing compositionVideoTrack[2];
It's already an array of pointers, so it's compatible with the type of the parameter ( AVMutableCompositionTrack**
). 它已经是一个指针数组,因此它与参数类型( AVMutableCompositionTrack**
)兼容。
Unless you're working with a property, you ought to do it like this (note that the method now returns the object of the same type): 除非您正在使用属性,否则您应该这样做(请注意,该方法现在返回相同类型的对象):
method constructor: 方法构造函数:
-(AVMutableCompositionTrack *)buildShow:(AVMutableCompositionTrack *)videoTracks {
// do something
return newVideoTracks;
}
And, method call: 并且,方法调用:
newVideoTracks = [self buildShow:compositionVideoTrack];
If you use a property, you can have a void method with no parameters. 如果使用属性,则可以使用不带参数的void方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.