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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:39:24+00:00 2026-06-10T12:39:24+00:00

I’m working on my first cocoa app from scratch and I’m a little confused

  • 0

I’m working on my first cocoa app from scratch and I’m a little confused about how to get my model, view, and controller working together. I’m sure I’m just missing something inane.

Basically, my view is currently set up to return 3 values to the controller. The controller takes those values and creates a new instance of a class. I want to be able to put those objects in an array and then work with the array.

First: The array I want to create… it is my model, right? How and where do I create it so that an action in the view (inputing the values) is interpreted by the controller correctly (creating the object) and then stored in the method?

Second: The attempts I have made leave me isolated from my array. I tried to create a class for the array, but I can’t access it from the controller. How do I get around this?

Lastly: I’ve been banging my head against the code for a few days. I’m teaching myself and I’m learning a lot but I have lots of simple questions like this. Thank you for taking the time to help. )

EDIT:

I’ve created the Student class. The Action sends the values to the controller and the controller creates a new instance:
- (IBAction)addNewStudentButtonPressed:(id)sender
{
Student *newStudent = [[Student alloc] initNewStudentwithName:[nameField stringValue]
andID:[idField intValue]
andLevel:[levelField stringValue]];
}

The Array is being created in the appDidFinishLaunching method:
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSMutableArray *roster = [[NSMutableArray alloc] initWithCapacity:100];
}

And now I want to add the student to the array. I’m just missing something obvious. 🙁

  • 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-10T12:39:26+00:00Added an answer on June 10, 2026 at 12:39 pm

    Think of the model as an active representation of what your program is dealing with – you need to show a list of students? Then you have to design a Student class with a bunch of properties [like I smell you already did].

    The controller acts as a bridge between the user and the model, and this connection is the view: you hit a button in the view, and you want a new student to be created therefore, and to be added to an array then.

    First, you need an array: you provide your Controller with such property/ivar – I’ll stick with ivar in this example:

    AppDelegate.h

    @interface AppDelegate : NSObject <NSApplicationDelegate>
    {
    
        //this is the array you will deal with inside Controller methods
        NSMutableArray* students;
    
        //you probably have some IBOutlets here:
        IBOutlet NSTextField* nameField;
        IBOutlet NSTextField* idField;
        IBOutlet NSTextField* levelField;
    
    }
    

    AppDelegate.m

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
    
        students = [[NSMutableArray alloc] initWithCapacity:100];
    
    }
    
    - (IBAction)addNewStudentButtonPressed:(id)sender
    {
    
        Student *newStudent = [[Student alloc] initNewStudentwithName:[nameField stringValue]
        andID:[idField intValue]
        andLevel:[levelField stringValue]];
    
         //now you add the student to the array
        [students addObject: newStudent]
    
    }
    

    The array is part of the logic, but not of the model itself – it’s just a controller basic field at the moment. Of course if you define a Classroom class with a list of students, you are wrapping the array inside another entity.

    Anyway the MVC matter is quite loose, and has many implementations – don’t let it overhelm you, just let the pattern help you to separate concerns and to have a smoother development, but don’t think of it as a dogma.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I don't have much knowledge about the IPv6 protocol, so sorry if the question

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.