How to set up single array or dictionary for use in multiple datasources?

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2009-08-01T10:04:40Z Indexed on 2010/04/05 4:03 UTC
Read the original article Hit count: 316

I have multiple TableViewDatasources that need to display list of objects form same pool depending of certain property. E.g.

object.flag1 is set- it will show up in TableView1
object.flag2 is set- it will show up in TableView2

The obvious way would be to have separate arrays for each TableView, But same object may appear in different arrays. Also I need to update objects very often or access all objects through same array.

How do I setup a single dictionary or array to have all objects in one structure?


To put it in another way: When table view or selection changes, application need to redraw TableViews with the new data. Application have to access the pool of objects and search through them using iterator and accessing each object and its properties.

I think that this is an expensive operation and want to avoid that. Perhaps maybe by making a global pool of objects a dictionary and exposing objects properties as dictionary fields.

So instead of iterating global pool of objects I could access global pool Dicitonary in a manner of database by selecting objects that has fields that match particular criteria.

Anyone know any example of doing that?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about arrays