Update Appdelegate Array From SubClass

I have a view that contains a subClass to accept files being dropped. The files are being dropped correctly and data is loading into my database. I also have a NSTableView that is bound to an array controller. The array controller is connected to my AppDelegate. When my application first loads the NSTableView populates correctly. My AppDelegate calls:

repeat with x from 0 to totalItems
   --other stuff
   testArray's addObject_(testItem)
end repeat
set my testArray to testArray

This populates the NSTableView when my application loads.
My AppDelegate also has a method that removes items from the NSTable bound to a button click.

tell testController to removeObjects_(selected)

This works as well.

Here is the issue. When I drop a file onto my View the Subclass I created for that view executes correctly, but how do I get the array to update? I tried to force a call to the appDelegate:

current application's TestAppDelegate's LoadTable()

The code is executed but the UI is never updated. (I assume this is because it calls a new instance of that AppDelegate and not the actual instance running)

So how do I get the actual array to repopulate from a UI subclass?
Perhaps I need to design a call differently? Is it possible to create and event that the AppDelegate hooks to?
I am open to all suggestions.

What does LoadTable do? Also, you say the the “view executes correctly”, what do you mean by that? Are you adding the dropped object to the array in you drop method? I think it would be helpful for you to show the code for LoadTable and for performDragOperation.

“view executes correctly” = the table on the screen shows rows added or removed with these two methods in the appdelegate.

two methods in the AppDelegate:

on LoadTable()
   set testArray to NSMutableArray's alloc()'s init()
   --DB select stuff
   repeat with x from 0 to totalItems
       testArray's addObject_(testItem)
   end repeat
   set my testArray to testArray
end LoadTable

on removeItems()
   set selected to testController's selectedObjects()
   --DB delete stuff   
   tell testController to removeObjects_(selected)
end removeItems

the subClass is on a Matrix on another part of the screen not on the NSTable itself.
one method In Subclass:

on performDragOperation_(info)
   set pb top info's draggingPasteboard()
   set theFiles to (pb's propertylistForType_("NSFilenamesPboardType"))
   --DB insert stuff

  --HERE is where I need to tell the Appdelegate (or something) to update NSTable
  current application's TestAppDelegate's LoadTable() -- does not work (runs LoadTable but does not update the UI. It makes sense why it doesn't though.)

end performDragOperation_

I can’t see from that code how your database relates to the table you’re populating. You said that the dropped items are correctly added to the database, how does that relate to testArray?

In AppDelegate:
LoadTable() - gets data from database, populates array, UI changes to show rows loaded
RemoveItems() - deletes data from database, calls removeObjects_(selected), UI changes to show rows removed

In SubClass:
performDragOperation() - saves data to database…
…but cannot call Loadtable in Appdeleage, or add items to the array because the array, and controller all are referenced in

It looks like you are using the variable testArray as both a local variable (set testArray to NSMutableArray’s alloc()'s init()) and a property (set my testArray to testArray). If so, that’s a really, really bad idea.

I solved the issue by setting the controller as a delegate for my main class and having other classes delegate that instance of the controller. No array needed. Array controller did all of the work.

property testController : missing value  --> multiple delegates.

I do not know if this is worse than my other approach, but this one is much cleaner.