Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jeanlain

macrumors 68020
Original poster
Mar 14, 2009
2,430
933
Hello. I have a tableview whose content is bound to an NSArrayController's arrangedObjects (nothing fancy here). The objects populating the table are entities with many attributes. The controllers is bound to a managed object context.
I want to observe changes in the controller's arrangedObjects property.

Every time I interact with the table in a way that should alter the property (filtering rows, sorting), it appears that this property is changed many times in a row. Like 13 to 20 times when I sort the view by clicking on a column header or when I add a new object to the controller's content. I cannot predict the number of time the property is going to be changed. It doesn't appear to be related with the number of objects populating the view. Note that the app behaves normally. In fact, I haven't noticed anything special before I decided to observe the property.
It doesn't happen to other views that are populated by "simpler" entities with fewer attributes, and bound to other controllers. The arrangedObjects property is changed just once.
Any ideas? :confused:
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
Without any code, interface files, or core data files, it's rather difficult for me to say why it's behaving that way... honestly, I've only just started my first Core Data Mac app, and I only had a tiny bit of experience with it on iOS... but I suspect if you share any of those files (or even your entire project... or a sampler of the project that exhibits the same behavior...) you'll get some helpful responses.

I would guess you might have some kind of race conditions occurring. IE, maybe different bindings are criss crossing each other and so when one value changes, it sets off a cascade of other changes? Just a guess based off of your description.
 

jeanlain

macrumors 68020
Original poster
Mar 14, 2009
2,430
933
I don't think my code should modify the arrangedObject property, when sorting the table for instance. My entities do not react to that. Anyway, this isn't a big issue, I was just wondering.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,750
8,422
A sea of green
I don't think my code should modify the arrangedObject property, when sorting the table for instance. My entities do not react to that. Anyway, this isn't a big issue, I was just wondering.

If you don't think it should be doing it, then use the debugger. Set a breakpoint on the method. Figure out when and where it's being called from. Work backwards.

You also seem to have another case with fewer calls. So use the debugger on that one, too. Same thing: set a breakpoint, trace who calls it, and work backwards. The goal is to see what a "normal" one looks like, then you can compare and contrast with the "abnormal" one.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.