Hey everbody.
I'm following the James Brannan tutorial's, and im trying to share data between some xbis. No luck.
I have 2 xib's. The first, simple button and textfield. The second, just a label, to show the result of the first xib textfield.
So, i dont know what im doing wrong. Im using NSObject like in tutorial.
SharedData.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface SharedData : NSObject {
NSString *MeuNome;
}
@property (nonatomic, retain) NSString *MeuNome;
@end
SharedData.m
#import "SharedData.h"
@implementation SharedData
@synthesize MeuNome;
- (void) dealloc {
self.MeuNome = nil;
[super dealloc];
}
@end
FirstStepViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "SharedData.h"
@interface FirstStepViewController : UIViewController {
IBOutlet SharedData *sharedData;
IBOutlet UITextField *campoNome;
}
@property (nonatomic, retain) UITextField * campoNome;
@property (nonatomic, retain) SharedData *sharedData;
- (IBAction) takeNextStep: (id) sender;
@end
FirstStepViewController.m
#import "FirstStepViewController.h"
#import "SecondStepViewController.h"
#import "LuconeAppDelegate.h"
@implementation FirstStepViewController
@synthesize campoNome, sharedData;
- (IBAction) takeNextStep : (id) sender{
// declaracao de shared data
[sender resignFirstResponder];
self.sharedData.MeuNome = self.campoNome.text;
// faz animacao para proximo slide
SecondStepViewController *varSecondViewController = [[SecondStepViewController
alloc] initWithNibName:@"SecondStepViewController" bundle:nil ];
[self.navigationController pushViewController:varSecondViewController
animated: YES];
[self navigationController].navigationBarHidden = NO;
}
- (void)viewDidLoad {
[self navigationController].navigationBarHidden = YES;
[super viewDidLoad];
}
- (void)dealloc {
self.sharedData = nil;
//self.campoNome = nil;
[super dealloc];
}
@end
SecondStepViewController.h
#import <UIKit/UIKit.h>
#import "SharedData.h"
@interface SecondStepViewController : UIViewController {
IBOutlet SharedData *sharedData;
IBOutlet UILabel *nome;
}
@property (nonatomic, retain) SharedData *sharedData;
@property (nonatomic, retain) UILabel *nome;
@end
SecondStepViewController.m
#import "SecondStepViewController.h"
#import "SharedData.h"
@implementation SecondStepViewController
@synthesize nome, sharedData;
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"step two";
self.nome.text = self.sharedData.MeuNome;
}
- (void)dealloc {
self.sharedData = nil;
[super dealloc];
}
@end
What's wrong?
Thanks!