tags:

views:

39

answers:

2

hi i am new to iphone. what i need is i have to call a function named (void)mymethod from classA to classB. how can i call pls post some code thank u in advance.

A: 

You need to create an object and then you can call a method on it. For example, you could have this in classA.

ClassB *object = [[ClassB alloc] init];
[object mymethod];
rickharrison
this gives a warning classA may not respond to mymethod,and in console it displays Application tryed to push nil view
MaheshBabu
A: 

hi mahesh,

Make Sure you have declared the previousCallMethod in MyPreviousClass.h file also.

MyPreviousClass *objMyPreviousClass = [[MyPreviousClass alloc] init];
[objMyPreviousClass previousClassMethod];

in your case (In ClassB)

ClassA *objClassA = [[ClassA alloc] init];
[objClassA mymethod];

But in this case also make sure you have declared mymethod in ClassA.h

hAPPY cODING...

Suriya