Can someone answer me how to call one method into another in Objective C on Xcode
Asked
Active
Viewed 2.9k times
5
-
This isn't very clear. Please try a longer description. Perhaps you are talking about @selector ? – Nimrod Oct 12 '10 at 04:02
-
suppose in didFinishinLaunchingmethod i have to call -(IBAction)check; method ...how can i call it?? – vidhya jain Oct 12 '10 at 04:08
-
Please consider using a more descriptive title for your question. This one is very general. – Johan Kool Oct 12 '10 at 05:17
4 Answers
18
The basic syntax for calling a method on an object is this:
[object method];
[object methodWithInput:input];
If methods returns value:
output = [object methodWithOutput];
output = [object methodWithInputAndOutput:input];
EDIT:
Here is a good example that how to call method from other class:
OBJECTIVE C - Objective-C call method on another class?
Example:
SomeClass* object = [[SomeClass alloc] init]; // Create an instance of SomeClass
[object someMethod]; // Send the someMethod message
5
You get a pointer to an object that implements the other method and send the appropriate message (e.g. [otherObject doSomething]
).

Chuck
- 234,037
- 30
- 302
- 389
1
If you have 2 functions inside class(.m file):
-(void) func1{ }
-(void) func2{ }
If you want to call func2 from func1, you cannot just call func2();
instead just include self
That is:
-(void) func1{
[self:func2];
}

Jeyhun Karimov
- 1,295
- 19
- 27