3
votes

I am trying to display content in NSTableView using NSMutableArrayController of NSMutableDictionary records.

I followed steps written below:

  1. In application delegate class, I created an NSMutableArray object with name 'geniuses' and stored some NSMutableDictionary objects with keys: 'geniusName' and 'domain'.

  2. I took an NSArrayController object in IB, binded its controller content property to application delegate class, and set its model key path to 'geniuses'. In attribute inspector pane set mode as class and class name as NSMutableDictionary. Added keys: 'geniusName' and 'domain' to it.

  3. In IB I took a table view object. Binded its content property to array controller, controller key path set as arranged objects. Binded value property of its first column to array controller, controller key path set as arranged objects, model key path set as 'geniusName'. Binded value property of its second column to array controller, controller key path set as arranged objects, model key path set as 'geniusName'.

After following these steps when I tried to build and run the project I found un-populated table view.

Can anyone suggest me where I may be wrong?

Thanks,

Miraaj

2
Ugh, that's a terrible file-sharing service. Might I suggest Google Docs, Dropbox, MobileMe, Bitbucket, or GitHub instead?Peter Hosey
ok.. I will definitely use the better file sharing services you suggested .. cheersDevarshi
you need to update the link to your code.. or better yet, just put it in the post. i have the same problem, but don't want to create a dupe question... so yours needs to be usable, please!Alex Gray
@alex... the file sharing service I used has dropped by code.. so I will not be able to share that code with you. Sorry !Devarshi
@alex... if you have the same problem.. then that is already answered for you over here ;)Devarshi

2 Answers

1
votes

I assume you have an instance variable declared for the mutable array:

NSMutableArray *myObjects;

But did you actually create the array?

The variable is merely a container for the pointer to an array object. You still need to create an array object and put its pointer in the variable, probably in your application delegate's init or initWithCoder: method.

Forgetting to do that is a common cause of the problem you're seeing. Until you create the array, the instance variable contains nil, and all attempts to put things into or retrieve things from the non-existent array are messages to nil, which do nothing.

1
votes

I can't check your code right now. How are you populating the genuises array? You must implement key-value-coding accessor methods and use those when inserting or removing data from an array in order to generate KVO notifications.