Any ideas why my controller's arrangedObjects is modified so many times?

Discussion in 'Mac Programming' started by jeanlain, Dec 9, 2012.

  1. jeanlain macrumors 65816

    Mar 14, 2009
    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:
  2. ArtOfWarfare macrumors G3


    Nov 26, 2007
    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.
  3. jeanlain thread starter macrumors 65816

    Mar 14, 2009
    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.
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    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.

Share This Page