View Full Version : Best way to update variable with Boolean , show YES in string.
trojanvillage
Oct 10, 2009, 08:07 PM
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.
trojanvillage
Oct 10, 2009, 09:17 PM
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?
firewood
Oct 10, 2009, 09:50 PM
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" ;
trojanvillage
Oct 11, 2009, 10:05 AM
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
dejo
Oct 11, 2009, 11:30 AM
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.
trojanvillage
Oct 17, 2009, 11:39 PM
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.
I see what you're saying, can you give me some example code showing the checkmark boolean property?
thanks for your help!
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.