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 8705835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:27:51+00:00 2026-06-13T03:27:51+00:00

I am currently learning Objective-C, one step at a time! Right now, my main

  • 0

I am currently learning Objective-C, one step at a time! Right now, my main focus is the MVC pattern. I’m not sure if I’ve wrapped around the concept very well yet.

So, a little bit of background info: I am currently experimenting with “entities” in my program. The model for the entities holds information such as health and speed. I’ve already implemented a very basic controller that can take advantage of this entity. The input is taken through a command line interface, which is basically my view.

Now, my question is: how should my entity controller access the information from the model property? I need to be able to have an array of the “entities” that the entity controller handles.

In my controller’s @interface: I have declared:

NSMutableArray *entities; 

Then in my @implementation for the controller, I override the init function. In this function:

entities = [[NSMutableArray alloc] init]; 

I also have another function that “spawns” a new entity.

- (void)spawnEntity {

Entity *entity = [[Entity alloc] init];
[entity setName:@"Default"];
...
...
[entities addObject: entity];
}

Then from main (which will later be a true view controller. Once I actually set up the app on the iPhone, as now I am just preparing the models and some of the controllers.):

EntityController *entityController = [[EntityController alloc] init];

[entityController spawnEntity];

Is this approach the correct way to utilize the MVC pattern? My main concern is the NSMutableArray I have declared in the controller. I am not sure if I am doing this properly.

Any feedback would be greatly appreciated.

Thank you.

-Steven

  • 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-06-13T03:27:52+00:00Added an answer on June 13, 2026 at 3:27 am

    You merged the Model and the Controller of your MVC design pattern in your EntityController. Sometimes, doing that can be the perfect fit, but there are some reasons you would want them apart from each other. A reason to split them would be to have easier to understand code as you add classes, methods and variables. Another reason would be reusability of your code.

    In your example, this could be possible by creating a new class for your model object which has an NSMutableArray instance variable. Your controller then could create an instance of that class (or a singleton) to add new entities to, rather than to its own array.

    If the array is the only variable you need for this application, though, you could perfectly stick with your current pattern. An NSArray (or one of its subclasses) is a model object on its own, so it would be unnecessary to wrap it in another class.

    For more info, see the Apple Docs.

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

Sidebar

Related Questions

I am currently learning objective-c from a book. In one example, before the class
I am currently learning objective c on my pc and my program will not
I've currently been learning Objective-C and Cocoa for some time but I feel that
I currently learning ASP.NET MVC . I wondered if it is possible when a
I am currently learning C and now I am upto the tutorial where I
I'm currently learning (by doing) objective-c by implementing a feature I felt is missing
I am currently learning Objective-C. I have created a class to hold information about
Im very new to Objective-C and am currently learning how to use Xcode and
I'm currently learning objective-c and I'm currently training with NSTableView. Here is my problem
I'm currently learning Objective C and in the process I've made the silly little

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.