NSArrayController Behavior


#1

The RaiseMan app works just fine; however, while investigating the NSArray Controller behavior I modified the setEmployees method by adding a couple of NSLog statements to see which route was being followed each time this accessor method was called. I was surprised to find out that a new array is assigned to the employees instance variable of my document object each time an employee is added or removed from the tableView. I had expected that the NSArrayController would simply call the addObject: and removeObject:atIndex: methods on the employees instance variable rather than completely replacing the array each time. Am I missing something here? This seems inefficient.
Thanks for any insight.


#2

Hi all,

I’m also very confused on how this thing works, in the first place. Would really want to understand that stuff before going on with this book.

  • Why would the setEmployee method be called once on each Person creation ? Who is calling it, and with what arguments?
  • Where do the creation of a new instance of the Person class and the associated setter methods get called from?From the ArrayController?
  • On page 139 of the printed book it mentions that key-value coding is used for this to work. Could someone explain the timeline of events?

I’m starting to think I’m to old for that stuff :slight_smile:


#3

I would also like to see an answer to BobParker’s question. I would have expected setEmployees to be called once when the array of persons was created, but it gets called every time the Add Employee button is pushed. Why is that? I don’t feel like I ‘get’ this chapter until I can understand this.