简体   繁体   English

如何在iOS中为方法调用调用和声明对象

[英]How to call and declare object for a method call in iOS

Say have "normal" class in iOS, called A. I'd like to pass this as a parameter to class B, method "myMethod". 假设在iOS中有一个名为“ A”的“普通”类。我想将此作为参数传递给类B的方法“ myMethod”。

"A" is declared as a pointer: 声明“ A”为指针:

A       *myA;

I'm unclear as to the syntax of call. 我不清楚call的语法。 Here's the method (I think this is probably correct: 这是方法(我认为这可能是正确的:

- (void *) myMethod:(A *) myA 

Should the call be 应该打电话吗

[b myMethod:myA] [b myMethod:myA]

or 要么

[b myMethod:&myA] [b myMethod:&myA]

Since myA is a pointer, it's seems it should be the second one, but somehow I'm thinking it's the first. 由于myA是一个指针,因此似乎应该是第二个指针,但是我以某种方式认为它是第一个。

It's the first: 这是第一个:

[b myMethod:myA]

I rarely dereference pointers in Objective-C as I used to do in C/C++. 我很少像过去在C / C ++中那样取消引用Objective-C中的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM