Binding NSMatrix Attributes for BOOL

I have a simple kernel object that has the boolean attribute subscribedToNewsletter . I designed my interface to represent this field as a group of radio buttons with Yes / No as text values ​​(and, obviously, Yes / No as BOOL values ​​for support).

I always considered myself great google-fu, but for life I can not find clear documentation:

  • How to bind the selected NSMatrix value (or is it a cell?) to the value YES / NO
  • how to bind text values ​​(if it is really necessary, I know that only there will ever be two values ​​- for sure, can they be hardcoded in Interface Builder or not?)

Next, it will be shown how to associate a radio group (with the text Male/Female ) with a String field called gender , which has M and F as possible values, but I disconnect.

Any pointers would be much appreciated. Thank you very much.

+4
source share
2 answers

I'm not sure that I have no answers, because: a) this is such a stupid question, or b) no one in the world knows how to do this. The latter does not seem likely to me, so I can only guess the first :)

In any case, just in case, if others are as stupid as I, I thought I would give some feedback on how I managed to achieve this.

In Interface Builder, I created NSMatrix with two cells of radio buttons with yes and no as the text for each of them, respectively. In the Attribute Inspector (command-1), make sure that the "Tag" field is set to "1" for the button cell "Yes" and set to "0" for the cell button "No". Then, in the Bindings inspector (command-4), bind the SelectedTag field for the matrix to a boolean property on your entity. Easy as a pie.

I am not saying that this is the best way ... just that it is effective.

+4
source

I found one solution for this part -

how to bind the selected NSMatrix value (or is it a cell?) Back value YES / NO

Here is a link to the problem I am facing and its solution - NSMatrix is ​​a simple binding question

Hope this helps!

-1
source

Source: https://habr.com/ru/post/1338399/


All Articles