davdroman / Bohr

Settings screen composing framework
MIT License
1.26k stars 83 forks source link

accessing text values of all cells #49

Closed JoeyBodnar closed 8 years ago

JoeyBodnar commented 8 years ago

this is less of an issue, and more of a question about how to use the library, since there isn't much documentation.

I'm using Bohr as a settings page. 3 of the cells are username, name, and email. Another cell is a button cell. The button cell saves the changed data from the other cells to the server. In the button cell, how can I access the text field values of the other cells? For example, in the main tableviewcontroller:

[section addCell:[BOButtonTableViewCell cellWithTitle:@"Save Info" key:nil handler:^(BOButtonTableViewCell *cell) {
        cell.actionBlock = ^{
           // usernamecell.Textfield.text here
          // emailcell.textfield.text here
          // API call to save new data to server here
          };
    }]];

any help would be appreciated, thanks

davdroman commented 8 years ago

This relates to #24. I've mentioned in previous issues how taking setting values from the cells directly is not a good practise. Rather, you should get any necessary values directly from NSUserDefaults, since they're the most accurate and raw representation of actual configuration data (a cell often formats such data to expose it in a comprehensive way to the user).

JoeyBodnar commented 8 years ago

ohhh ok I see now. I saw the "key" in the setup for each cell, but didn't know that corresponded to an NSUSerDefaults key. I thought there was some [BOTextTableViewCell valueForKey@""]; method or something like that and couldn't find it and was confused. thanks a lot!