MainViewController.h
@class EventViewController;
@class MainViewController;
@interface MainViewController : UIViewController {
EventViewController *eventViewController;
MainViewController *mainViewController;
//extern int i;
@public
NSString *titlegame;
}
@property (retain,nonatomic) EventViewController *eventViewController;
@property (retain,nonatomic) MainViewController *mainViewController;
@property (retain,nonatomic)IBOutlet NSString *titlegame;
@end
MainViewController.m
-(IBAction)buttonClick:(id)sender{
titlegame = [sender titleForState: UIControlStateNormal];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"You selecet!!!!"
message:titlegame
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
//[titlegame release];
[alert release];
////////
if([titlegame isEqualToString: @"FootBall"]==YES)
NSLog( @"Equal");
else
NSLog( @"NotEqual");
EventViewController *eventController = [[EventViewController alloc]
initWithNibName: @"EventView"
bundle:nil];
self.eventViewController = eventController;
[eventController release];
[[self mainViewController] dismissModalViewControllerAnimated:YES];
[eventViewController.view removeFromSuperview];
[self.view addSubview: eventController.view];
// eventController.labelgame.text = titlegame;
eventViewController.labelgame.text =titlegame;
NSLog(@"title==>%@",eventController.labelgame.text);
NSLog(@"title1==>%@",eventViewController.labelgame.text);
[eventViewController.labelgame retain];
}
it works properly
but in EventViewController's ViewDidLoad method i cant that label's value..
EventViewController.m:
- (void)viewDidLoad {
NSLog(@"titlegame==>%@",labelgame.text);
}
EventWiseViewController.m:
-(IBAction)BackPressed :(id) sender
{
EventViewController *eventController = [[EventViewController alloc]
initWithNibName: @"EventView"
bundle:nil];
self.eventWiseViewController = eventController;
[eventController release];
[[self eventWiseViewController] dismissModalViewControllerAnimated:YES];
[eventViewController.view removeFromSuperview];
[self.view addSubview: eventController.view];
NSLog(@"final=---->%@",eventController.game1);
eventController.labelgame.text = mainViewController.titlegame;
NSLog(@"gmename1 ==>%@", [mainViewController titlegame]);
NSLog(@"gamename2 ==>%@", mainViewController.titlegame);
//NSLog(@"gmename1 ==>%@",eventController.labelgame.text);
//NSLog(@"gmename2 ==>%@",eventController.game1);
}
but here when i go back to EventViewController the label get blank ,why?? plz tell me..