"best practice"

  • At work, we use 2 large totally separate databases to look up codes needed for coding procedures.
    I have written a simple app to present the data, using bindings. Implemented a search-field (binding based) and all works well.
    My question is one of an approach. (There is a paucity for this type of approach in the archives, which in of itself, probably means something!)
    I would like to be able to "toggle" between the 2 databases using the same interface( i.e. the same tableView and searchField)(The tableView in one would need an extra column). I thought perhaps of setting up 2 tableViews/searchFields and simply toggling (hide/show) between the 2 databases.
    Other than simply having 2 separate apps, could anyone suggest an approach that I have missed.
    I would be grateful for any insights that the group might have.
    Thank you.
  • On Jun 20, 2012, at 11:00 PM, Michael de Haan wrote:

    > I would like to be able to "toggle" between the 2 databases using the same interface( i.e. the same tableView and searchField)(The tableView in one would need an extra column). I thought perhaps of setting up 2 tableViews/searchFields and simply toggling (hide/show) between the 2 databases.
    > Other than simply having 2 separate apps, could anyone suggest an approach that I have missed.

    Um, a pop-up button or radio button or segmented control for selecting the database?
    You definitely don't need two identical sets of table views!

    —Jens
  • On Jun 20, 2012, at 11:26 PM, Jens Alfke wrote:

    >
    > On Jun 20, 2012, at 11:00 PM, Michael de Haan wrote:
    >
    >> I would like to be able to "toggle" between the 2 databases using the same interface( i.e. the same tableView and searchField)(The tableView in one would need an extra column). I thought perhaps of setting up 2 tableViews/searchFields and simply toggling (hide/show) between the 2 databases.
    >> Other than simply having 2 separate apps, could anyone suggest an approach that I have missed.
    >
    > Um, a pop-up button or radio button or segmented control for selecting the database?
    > You definitely don't need two identical sets of table views!

    Is the approach therefore to create the bindings to the databases, as well as the searchField  in code ( as opposed to IB)?
  • On Jun 20, 2012, at 11:00 PM, Michael de Haan wrote:

    > I thought perhaps of setting up 2 tableViews/searchFields and simply toggling (hide/show) between the 2 databases.

    I think that's a fine alternative: simplest coding, uses more memory, whether the difference is important to your app or not I don't know. The other approach of course: use a single table view, and programmatically switch its contents by switching out columns & bindings.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.elevated-dev.com/
    (303) 722-0567 voice
  • Thanks to both of you.
    Much appreciated.
    On Jun 20, 2012, at 11:48 PM, Scott Ribe wrote:

    > On Jun 20, 2012, at 11:00 PM, Michael de Haan wrote:
    >
    >> I thought perhaps of setting up 2 tableViews/searchFields and simply toggling (hide/show) between the 2 databases.
    >
    > I think that's a fine alternative: simplest coding, uses more memory, whether the difference is important to your app or not I don't know. The other approach of course: use a single table view, and programmatically switch its contents by switching out columns & bindings.
    >
    > --
    > Scott Ribe
    > <scott_ribe...>
    > http://www.elevated-dev.com/
    > (303) 722-0567 voice
    >
    >
    >
    >
  • On Jun 20, 2012, at 11:32 PM, Michael de Haan wrote:

    > Is the approach therefore to create the bindings to the databases, as well as the searchField  in code ( as opposed to IB)?

    You can do that. It's not hard to set and remove bindings in code.

    Another possibility is to create your own class as an intermediary. It observes one database or the other and exposes the data as observable properties. You then instantiate one of those in the nib and bind the UI elements to it. Then you can switch the object's state from viewing one database to the other (maybe by changing an "inputSource" property?) This is also a good approach because it decouples your UI implementation from the details of how you get the data to display in it.

    —Jens
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today