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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:23:16+00:00 2026-06-09T11:23:16+00:00

I’m writing my first master detail view in Cocoa. My data model is really

  • 0

I’m writing my first master detail view in Cocoa. My data model is really simple: just an NSMutableArray that contains instances of a single class having a few NSStrings properties.

Here’s what I’ve created so far:

  • A class representing the instances.
  • An NSMutableArray specified as a property of my app delegate to hold the class instances.
  • A master detail view, with an NSTable and some text fields to hold the properties of a selection instance.
  • An NSArrayController with a binding specifying the app delegate, and the name of the NSMutableArray property as the model key path.
  • Bindings between the columns of the NSTable and the NSArrayController (controller key = “arrangedObjects”, and model key path of each column = a property of the class).
  • Bindings between the text fields of the view and the selection (controller key = “selection”, and model key path of each text field = a property of the class).
  • A “+” button and a “-” button in the view to enable adding and removing objects.

However, I’m having two problems with this design:

(1) I can’t find a good way to implement the “+” and “-” buttons. First, I bound them to the add: and remove: properties of the array controller. While this seems to work, it has a problem: my class declares an init member that initializes the NSStrings to stub values, but the array controller doesn’t seem to [init] the new instances, because the new list entry has empty strings for each column.

Next, I attached them to IBActions in my app delegate that added or removed an object from the NSMutableArray. However, this feels wrong – it feels like I’m violating the model-view-controller architecture by not talking to the array controller. For example, the “-” function has to talk to the array controller to get the selected item. Also, I notice that I have to send a [didChangeValueForKey] message after altering the array – which feels like a signal that I’m doing this wrong.

(2) One of the detail subviews in my view is an NSTextView that’s bound to an NSString in the selected object. It really isn’t working as expected: when new text is entered, the text remains the same even if other members of the class (which should have different values) are selected. Also, the text data isn’t being saved to any instance of the class.

Any thoughts? Thanks in advance.

  • 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-09T11:23:17+00:00Added an answer on June 9, 2026 at 11:23 am

    Here is an example that should be close to what you want:

    #import "AppDelegate.h"
    #import "Members.h"
    
    @implementation AppDelegate
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
        self.theData = [NSMutableArray arrayWithObject:[[Members alloc] init]];
    }
    
    -(IBAction)addMember:(id)sender {
        [self.controller addObject:[[Members alloc] init]];
    }
    
    -(IBAction)removeMember:(id)sender {
        [self.controller removeObjectAtArrangedObjectIndex:self.controller.selectionIndex];
    }
    

    The array controller (whose IBOutlet is controller) has its content array bound to theData. Members is the name of my class that has 3 string properties, name, author and blurb. In the detail view, the 2 text field’s are bound to ArrayController.selection.name or author, just like you said you did. The other property, blurb, is bound the same way (ArrayController.selection.blurb), but to the Attributed String value of a text view. This worked fine, I’m not sure what your trouble with the text view was. If I add text to the text view, it does show up there if I click another row in the mater table and then click back (also if I log the array, it shows up there too).

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.