In Class1 I have a var named “cDte1”. I would like to set it from Class2.
Class1.h:
@interface Class1 : UIViewController {
NSString *cDte1;
}
@property (readwrite,assign) NSString *cDte1;
@end
In Class2.m I imported the Class1.h
I then tried this from Class2
Class1.cDte1 = @"test";
but that doesn’t work. What did I do wrong?
EDIT, more info. If I need to set the var and then show the view the code below doesnt work as I assume there are 2 difference instances of the class?
Class1 *obj = [[Class1 alloc] init];
Class1 *myView = [[Class1 alloc] initWithNibName:@"Class1" bundle:[NSBundle mainBundle]];
obj.cDte1 = @"7/25/2011";
[self presentModalViewController:myView animated:YES];
[myView release];
[obj release];
You set member variables on instances of classes, not classes.
So you can do something like:
edit: in your example, try: