如何从Objective C中的另一个方法调用方法?

vid*_*ain 5 xcode objective-c

有人可以回答我如何在Xcode上的Objective C中将一个方法调用到另一个方法

Nav*_*eed 18

在对象上调用方法的基本语法是:

[object method]; 
[object methodWithInput:input]; 
Run Code Online (Sandbox Code Playgroud)

如果方法返回值:

output = [object methodWithOutput]; 
output = [object methodWithInputAndOutput:input];
Run Code Online (Sandbox Code Playgroud)

更多详情


编辑:

这是一个很好的例子,说明如何从其他类调用方法:

目标C - 另一个类的Objective-C调用方法?

例:

SomeClass* object = [[SomeClass alloc] init]; // Create an instance of SomeClass
[object someMethod];                          // Send the someMethod message
Run Code Online (Sandbox Code Playgroud)


Chu*_*uck 5

您将获得指向实现其他方法的对象的指针并发送相应的消息(例如[otherObject doSomething]).