Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your array controller is observing your App Delegate's "array" property. That means KVO notifications are sent only when the array object is set, not when objects are added to it. It sounds like you are using an NSMutableArray and adding objects to it, which explains why the Array Controller is not being notified of changes, because the underlying object is not changing.</p> <p>The easy solution is to wrap your calls in a will/did change block like so:</p> <pre><code>[self willChangeValueForKey:@"array"]; [self.array addObject:[NSDictionary dictionaryWithObject:@"foo" forKey:@"name"]]; [self.array addObject:[NSDictionary dictionaryWithObject:@"bar" forKey:@"name"]]; [self didChangeValueForKey:@"array"]; </code></pre> <p>This manually notifies observers that there has been a change to the "array" property.</p> <p>Long answer: You're doing it wrong. The whole point of having an array controller is to shift the work of managing the array to the controller class itself, so it manages the underlying array, sends out the right notifications, maintains state, etc. without you having to sweat the implementation details. A better solution would be to unhook the content array binding and just add objects to the array controller directly like so:</p> <pre><code>[arrayController addObject:[NSDictionary dictionaryWithObject:@"foo" forKey:@"name"]]; [arrayController addObject:[NSDictionary dictionaryWithObject:@"bar" forKey:@"name"]]; </code></pre> <p>This works because the array controller manages its own array internally.</p> <p>The best solution is to use Core Data. NSArrayController is designed to be used with it. You also get a whole bunch of things for free, like persistentce, undo support, object relationsips, and the ability to add objects without writing code just by calling <code>add:</code> on the array controller directly from your UI controls.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload