Hi there
I know im missing something but my friend and I can figure out what.
Firstly.. I have two .hs and .ms that I'd like to share data between - two view controllers In the first .h i have this - that makes the variables and properties them
//top half of .h
//Passing to Submit Page
NSMutableString *messageString;
NSInteger theirTime;
}
@property (nonatomic, readwrite) NSInteger theirTime;
@property (nonatomic, retain, readwrite) NSMutableString *messageString;
/actions
@end
Then in the respective .m - sythesize them
@synthesize messageString, theirTime;
then from the new .h and .h i need to acces them.. so In view did load i do this
- (void)viewDidLoad {
messageString = [[NSMutableString alloc] init];
MemoryViewController *controller = [[MemoryViewController alloc] init];
timeInSeconds = controller.theirTime;
NSLog(@"Time = %d", timeInSeconds);
messageString = controller.messageString;
NSLog(@"Message - %@", messageString);
[controller release];
NSUserDefaults *HighScore = [NSUserDefaults standardUserDefaults];
bestTime.text= [NSString stringWithFormat:@"Best Time:%d", [HighScore integerForKey:@"integerKey"]];
currentTime.text = [NSString stringWithFormat:@"Current Time:%d", timeInSeconds];
[super viewDidLoad];
}
and at the top
#import "MemoryViewController.h"
and now the .h to show you all what the variables are
IBOutlet UILabel *bestTime;
IBOutlet UILabel *currentTime;
int timeInSeconds;
NSMutableString *messageString;
So. In short - I made variables made properties, and synthesized them, then in the view i make an instance of the other VC, then try use them to do things
Log out put
2010-04-15 20:53:09.105 Memory[3538:207] Time = 0
2010-04-15 20:53:09.107 Memory[3538:207] Message - (null)
Any ideas guys would be great... if you need more code/ less code just say.. ive tried other blogs but they all do it with app delegates.. and i dont like global variables.
Cheers
Sam