John Howard
John Howard

Reputation: 64225

Cocoa - Bound Array is empty when trying to write

I am writing a Master-Detail program in XCode, and want to add the ability to save all the data the user has put in. Currently I have an assignmentArray (NSMutableArray) in my controller object that is bound to an NSArrayController. When clicking a button, it should add an instance of my model object to the array. This appears to work fine. However, when I try to save it, the array is empty. As far as I have seen from debugging, the array is always empty. Why is it not containing these objects? I followed this tutorial and my code doesn't have any errors or warnings.

Upvotes: 1

Views: 67

Answers (2)

user693410
user693410

Reputation: 905

Make sure you have bound your ArrayController to File's Owner and not an instant of your controller!

Upvotes: 1

John Howard
John Howard

Reputation: 64225

The problem was that I bound the ArrayController to the model object instead of File's Owner. Changing this fixed the problem.

Upvotes: 1

Related Questions