user1051935
user1051935

Reputation: 589

Calling a function inside the same class objective C

I am new to Objective C and I couldn t find resources on this subject at all

let s say I have a function Called A and a function called B , both belong to the same Class , how should I call function B inside of function A ? assuming they both belong to a Class called C

Thanks

Upvotes: 2

Views: 3725

Answers (3)

Duncan Babbage
Duncan Babbage

Reputation: 20187

Objective C has methods rather than functions, though it does support C functions. To call a method called B inside the current class, you send a message to the current instance of the class, i.e. "self", calling its method B:

[self B];

This presumes that the method B is defined:

-(void) B {
// Whatever method B does, it does not require any parameters.
}

Upvotes: 2

Gabriel
Gabriel

Reputation: 3045

//other code inside your project

-(void) functionA
{
NSLog(@"Hello"); // not sure if the syntax for this is right, but it should be

}

-(void) functionB
{
[self functionA];
}

Upvotes: 5

Robert Kang
Robert Kang

Reputation: 568

call [self B] in A.

This would be a good start: http://cocoadevcentral.com/

Upvotes: 3

Related Questions