Best way to update variable with Boolean , show YES in string.

Discussion in 'iOS Programming' started by trojanvillage, Oct 10, 2009.

  1. trojanvillage macrumors member

    Joined:
    Jan 1, 2008
    Location:
    Toronto
    #1
    Hello All,
    I'm looking for the best way to implement what I'm sure is an easy thing to do.
    I have a table view with each cell representing a variable. When you click each cell, it will show a checkmark and save somewhere that it has been checked with a boolean value. In another view, I want the check marked variables to be listed as a string, or some related way. This new view would check to see what variables Boolean is updated every time it redraws.

    So, how do I go about doing this, and is there an easier way than what I have planned in my head?

    Thanks you for your Help,

    Wes.
     
  2. trojanvillage thread starter macrumors member

    Joined:
    Jan 1, 2008
    Location:
    Toronto
    #2
    If possible, can I / how do I do this with a .plist? Can I simply send the plist a message to toggle the boolean YES/NO and then have the other view read the plist?
     
  3. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #3
    Build a model controller to contain the state of your variable(s). Call Boolean getters & setters in that model controller from the handlers for the checkbox view initialization and action delegates.

    You then could also do a getter from that model than returns a string object, and call that string getter from wherever you want to display a string representation in a view.

    I think this falls under the MVC paradigm.

    Me, I would just use a global, less lines of coding:
    BOOL foo;
    extern BOOL foo;
    foo = YES;
    myString = foo ? @"YES" : @"NO" ;
     
  4. trojanvillage thread starter macrumors member

    Joined:
    Jan 1, 2008
    Location:
    Toronto
    #4
    do u know of a good resource that has a detailed example? Also, does anyone know where I can get a good example of using plists for updating variables.

    thanks
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    First, what's the strong desire to use plists? What are you hoping it'll do that other solutions won't?

    Second, the usual approach for a tableview is to have an array of objects as the data-source for the table. Depending on your needs, often you'll create a new class to model this object, and then you can add your checkmark boolean as a property of this class.
     
  6. trojanvillage thread starter macrumors member

    Joined:
    Jan 1, 2008
    Location:
    Toronto
    #6
    I see what you're saying, can you give me some example code showing the checkmark boolean property?

    thanks for your help!
     

Share This Page