//
// ViewController.h
//
// Created by Weerachai on 10/27/55 BE.
// Copyright (c) 2555 Weerachai. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
IBOutlet UITextField *txtName;
}
- (IBAction)btnSubmit:(id)sender;
@end
ViewController.m
//
// ViewController.m
//
// Created by Weerachai on 10/27/55 BE.
// Copyright (c) 2555 Weerachai. All rights reserved.
//
#import "ViewController.h"
#import "DetailController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[txtName release];
[super dealloc];
}
- (IBAction)btnSubmit:(id)sender {
NSString *name = [txtName text];
DetailController *view2 = [[[DetailController alloc] initWithNibName:nil bundle:nil] autorelease];
view2.detailItem = name;
[self presentViewController:view2 animated:NO completion:NULL];
}
@end
DetailController.h
//
// DetailController.h
//
// Created by Weerachai on 10/27/55 BE.
// Copyright (c) 2555 Weerachai. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DetailController : UIViewController
{
IBOutlet UILabel *lblResult;
}
@property (strong, nonatomic) id detailItem;
@end
DetailController.m
//
// DetailController.m
//
// Created by Weerachai on 10/27/55 BE.
// Copyright (c) 2555 Weerachai. All rights reserved.
//
#import "DetailController.h"
@interface DetailController ()
@end
@implementation DetailController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
lblResult.text = [self.detailItem description];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[lblResult release];
[super dealloc];
}
@end