Hi,
I am trying to keep close to the MVC approach to programming in an objective C application.
I have a model class and two View Controllers.
@interface Disc : NSObject {
NSString *discType;
NSNumber *capacity; }
@property (nonatomic,retain) NSString *discType;
@property (nonatomic,retain) NSNumber*capacity;
@implementation Disc
@synthesize discType,capacity;
Then for View Controller A
@interface DiscTypeViewController : SecondLevelViewController {
NSString *discTypeSub;
}
@property (nonatomic,retain) NSString *discTypeSub;
@end
@implementation DiscTypeViewController
@synthesize discTypeSub;
Now, I know I can access the members of the model (disc) class from View controller A
Disc *disc1 = [[Disc alloc]init];
[disc1 setDiscType:@"DVD"];
discTypeSub = [disc1 discType];
This returns the value "DVD" which is fine.
The question is, how can my Second View Controller access that same String that returned "DVD". There's no point in initializing a new instance of Disc. I need the values that were created from View Controller A calling the setter/getter methods of the Disc class.
What is the best design approach for such a scenario, any info would be much appreciated.