ios - Update UILabel based on selected table view rows -


i have table view , text field. whatever person selects in table view appear in textfield.

example: in table view choices "one" "two" "three"

if select "one", checkmark appears on tableview , "one" appear in text field well.

i know how add strings using stringbyappendingstring, when select "two", , "one" still selected, label appear "onetwo"

now question: if deselect "one" choice (or other choice matter), how can delete portion of concatenated string?

example: if selected in order "threeonetwo" , wanted deselect "one", label appear "threetwo".

thank you.

update: have done far , stuck.

first: created mutable array:

nsmutablearray *tobefilledtabledata;

then allocated it:

tobefilledtabledata = [[nsmutablearray alloc] init];

then, if user selects option table view, add 1 object:

[tobefilledtabledata addobject:@"one"];

i changed mind on having textfield appear "threeonetwo", i'd add semicolon in between instead want appearance "three;one;two". created string add semicolon @ end:

nsstring *combinedforces

combinedforces = [tobefilledtabledata componentsjoinedbystring:@";"]; (^ not displaying semicolon instead i'll add semicolon addobject [unless there way it])

then displayed object in text field:

textfield.text = combinedforces;

so of right now, 1. list not populating click more options , 2. inserting semicolon in between each choice becoming puzzle. i'd appreciate =)

instead of deleting portion of string, maintain array or set selected items.

in didselectrowatindex path method add selected string array (or remove it) , call updatelabel method, creates string contents of array or set.

thus, string recreated every time change happens.


if want know order of selection, use nsmutableorderedset, if don't need know order, can use nsmutableset.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -