Actually i am testing a sample application in iPhone...where in user interface if i press a button "hello" message should display on text field...such a way that when button pressed it should call a method present in another class i.e, from class2 and display a message on UI so Please help me.... the following code is given below i have two classes say class1 and class2... in class1 i am calling
class1.h
@interface class1 : UIViewController {
IBOutlet UILabel *statusText;
}
@property (nonatomic,retain)UILabel *statusText;
- (void)buttonpressed:(id)sender;
@end
class1.m
@implemenation class1
-(IBAction)sayhello:(id)sender
{
class1ViewController *class = [[class1ViewController alloc]init];
[class hello];
}
class2.h
@interface class2 : UIViewController {
UILabel *statusText;
}
@property(nonatomic,retain)UILabel *statusText;
-(void)sayhello:(id)sender;
@end
class2.m
@implementation class2
-(void)sayhello:(id)sender;
{
NSString *newtext = [[NSString alloc] initWithFormat:@"hello"];
statusText.text = newtext;
[newtext release];
}
Please suggest what changes I should make in the code so that when I press a button it should display the message "HELLO" by calling a method in another class.... I have taken two classes.. I have used IBAction methods... I want to call a method using another class.
thanks a lot in advance...