Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 889773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:37:13+00:00 2026-05-15T13:37:13+00:00

I am trying to keep close to the MVC approach to programming in an

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:37:14+00:00Added an answer on May 15, 2026 at 1:37 pm

    You could create some sort of a context object. Most likely it would be a SingleTon or Factory (static getters/setters). You can have a dictionary with keys @”DVD” or @”BlueRay” with values of type Disk.
    Please consider that these objects will reside in your memory while stored in you cache dictionary. Consider to use NSCache if you target iOS4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two versions of my app. I'm trying to keep a copy of
I have an alert script that I am trying to keep from spamming me
Trying to keep all the presentation stuff in the xhtml on this project and
I'm trying to keep dependencies to a minimum for a program I contribute to,
I'm creating a threaded message board and I'm trying to keep it simple. There's
I am trying to construct a way to keep certain hard drive partitions/usb drives
im trying to kick off a Runnable classes run method however i keep getting
I'm trying to do a simple erase and keep getting errors. Here is the
I'm trying to use the CRT memory leak detection but I keep getting the
I'm trying to use slime from CVS (2009-01-05) but keep getting this error: LOAD:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.