Tutorial details

Passing Data Between Views | App Code for Sale | Preview

Passing Data Between Views | iOS Tutorial

How to pass data between views

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcodepassingdataviews.htm

In this tutorial i will be showing you how to pass data between views


  • 1 Label
  • 1 UITextField
  • 2 Buttons

Passing dada between views is very handy if you require content to move throughout you application its also very helpful for games where your score or info can be passed to the next view where theres leader boards or extra content

ViewController.h PAGE TOP

#import "secondview.h"
@interface ViewController :UIViewController {
secondview *secondviewData;
IBOutlet UITextField *textfield;
@property (nonatomic, retain)secondview*secondviewData;

ViewController.m PAGE TOP

#import "ViewController.h"
#import "secondview.h"
@implementation ViewController
@synthesize secondviewData;
-(IBAction)passdata:(id)sender {
secondview *second = [[secondview alloc] initWithNibName:nil bundle:nil];  
self.secondviewData = second; 
secondviewData.passedValue = textfield.text;
    [self presentModalViewController:second animated:YES];

SecondView.h PAGE TOP

@interface secondview :UIViewController {
IBOutlet UILabel *label;  
NSString *passedValue;
@property (nonatomic, retain)NSString *passedValue;

SecondView.m PAGE TOP

#import "ViewController.h"
@implementation secondview
@synthesize passedValue;
-(IBAction)back:(id)sender {
ViewController *second = [[ViewController alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:second animated:YES];
- (void)viewDidLoad
label.text = passedValue;
    [super viewDidLoad];
// Do any additional setup after loading the view from its nib.

Reference PAGE TOP


0 Comments Leave a comment

Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.