简体   繁体   English

如何在方法中使用此值 - 目标C.

[英]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.

相关问题 如何从目标c库中调用抽象方法 - How can i call an abstract method from an objective c library 如何将字符串从Objective-C传递给C函数并取回值? - How can I pass a string to a C function from Objective-C and get a value back? 我如何使用GET方法JSON Objective C在NSRequestURL中传递特殊字符(如#,@,%,$) - How can i pass special character(like #,@,%,$) in NSRequestURL with GET method JSON Objective C 如何在Objective-C中将类的属性作为方法的参数传递 - How can I pass a property of a class as a parameter of a method in objective-c 如何检查目标C中的RequestBody in Post方法是否附加了我的数据 - How can i check that my data is attached with the RequestBody in Post method in Objective C 如何在父视图中调用方法? (iPhone / Objective-C) - How can I call a method in parent view? (iPhone/ Objective-C) Phonegap:如何通过Objective-C在Webview内部的index.html中添加哈希值? - Phonegap: How can I add a hash value to index.html inside webview via Objective-C? 我如何从Objective-C的xml文档中读取整数值 - how can i read the integer value from xml document in objective-c 如何在Objective-C中使用一个类中另一个类的变量值? - How can I use the value of a variable from one class in another in Objective-C? 我如何在目标C中交换没有第三个变量的两个变量的值 - how can i swap value of two variables without third one in objective c
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM