• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Modifying NSMutableArray controlled by NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Modifying NSMutableArray controlled by NSArrayController


  • Subject: Modifying NSMutableArray controlled by NSArrayController
  • From: email@hidden
  • Date: Tue, 13 Sep 2005 04:47:03 -0700

Hello list,

Can I modify the NSMutableArray "under" the NSArrayController that controls it? Here's what I'm doing:

I've got an NSMutableArray* in my controller class, with an accessor ("foo") for it. I did the following in IB:

1. Created an NSObjectController and connected the content outlet of the NSObjectController to my controller instance.
2. Created an NSArrayController and set the bindings contentArray to the selection of the NSObjectController, with model key path "foo".
3. Added an NSTableView with one column, and set the table column's value binding to the NSArrayController's arrangedObjects.


If I populate the NSMutableArray with a couple objects in my init method, those objects display in the table. Everything works as expected so far, but I run into trouble when programatically adding items to the NSMutableArray.

If I add an item to the NSMutableArray, the table does not update to show the new item. I added a reference to the table view in IB and tried [tableView reloadData], but no joy.

I did manage to get it to work by adding a reference to the NSArrayController to my controller class and wiring it up in IB, then changing code to call [arrayController addObject:] instead of [fooArray addObject:]. Is this the recommended idiom? Is it okay to have a reference to the NSArrayController in my controller class like this? It seems funny to need a reference to the array and a reference to the array controller (which has a reference to the array).

Am I doing this right?

Thanks.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Modifying NSMutableArray controlled by NSArrayController
      • From: Scott Anguish <email@hidden>
References: 
 >[Moderator] Cocoa and list resources (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: Question about floatValue on nil object
  • Next by Date: Re: How to add toolbar into Mail.App
  • Previous by thread: [Moderator] Cocoa and list resources
  • Next by thread: Re: Modifying NSMutableArray controlled by NSArrayController
  • Index(es):
    • Date
    • Thread