Hi there, I'm pretty new to iPhone development.
I am building an app which has multiple views and controllers. There is only one model.
I need to share the model amongst all of the controllers; so I have instantiated the model inside the App Delegate header file:
@interface MyAppDelegate
(...snip...)
@property (nonatomic, retain) CalcModel *model;
and then synthesized it accordingly.
Inside a controller, I have tried to reference the model like so:
CalcModel* model = [[[UIApplication sharedApplication] delegate] model];
The problem is that the compiler says '-model' not found in protocol
This is probably because the delegate field returns the protocol type, not the concrete MyAppDelegate type... so should I cast [[UIApplication sharedApplication] delegate] to MyAppDelegate, so I can access the model property? If so, how?
Or is this all wrong? More broadly, how would you share a model amongst view controllers?
many thanks for your help