1

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

user1051935
  • 579
  • 1
  • 10
  • 29

3 Answers3

5
//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];
}
Gabriel
  • 3,039
  • 6
  • 34
  • 44
  • Even if this solves your problem, I strongly recommend you learn some more about objective c before trying to make anything... – Gabriel Nov 23 '11 at 20:39
3

call [self B] in A.

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

Daniel
  • 30,896
  • 18
  • 85
  • 139
Robert Kang
  • 568
  • 5
  • 19
  • 1
    This http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf will be a much better place to start – Denis Nov 23 '11 at 20:38
2

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.
}
Community
  • 1
  • 1
Duncan Babbage
  • 19,972
  • 4
  • 56
  • 93