Pregunta

I am badly struck in a issue where I am trying to populate the nestableview lazily. Below is my approach.

I have created a custom class PRIList where it has an instance of array to manage the models. I have bound the priList.items to the array controller in the xib where items is not an instance in PRIList but to support lazy loading I have implemented the methods countOfItems and objectInItemsAtIndex:.

Initialy when I populate the PRIList I populate few objects (say 50) with valid objects and rest with the faulty objects. In the objectInItemsAtIndex I check if the item at particular index is valid or faulty. If it is faulty I fetch next set of 50 objects.

What I understand is NSArrayController calls the method objectInItemsAtIndex for only the visible rows in the table view. But the problem here is as soon as set the PRIList the objectInItemsAtIndex method is called for all the objects. This is even called when some selection is changed in table view (the stack trace shows this method is called from [_NSModelObservingTracker startObservingModelObjectAtReferenceIndex])

Basically I want to fetch the records whenever the user scrolls down in the table view.

I followed the same approach in a different project in Lion. It worked there. Currently I am in Mavericks.

I tried overriding the isCompatibleWithResponsiveScrolling in the custom table view and returned it to NO. Still no luck.

Any help is very much appreciated.

¿Fue útil?

Solución

First, have you assigned or bound the sort descriptors of the array controller? Or set any columns to automatically generate sort descriptors? (I'm not sure that latter is relevant. It depends on whether the column is sorted by default.)

In any case, if the array controller feels the need to sort the objects in order to arrange the objects, then it will need to load all of the contents. I was under the impression that it always does so, anyway, although you report that it works.

For an issue like this, I'd recommend that you go for full manual control. That means not using bindings or an array controller. Use a data source.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top