What does AlwaysUsesMultipleValuesMarker do in NSTreeController? - nstreecontroller

According to Apple's documentation,
setAlwaysUsesMultipleValuesMarker:
Sets whether the receiver always returns the multiple values marker when multiple objects are selected, even if they have the same value.
- (void)setAlwaysUsesMultipleValuesMarker:(BOOL)flag
Discussion:
Setting flag to YES can increase performance if your application doesn’t allow editing multiple values. The default is NO.
However, I have trouble understanding what this all means even after reading the documentation. Can anybody offer a simpler explanation with examples?

Found the answer to this question deep inside apple docs on Cocoa Binding Guide.
NSMultipleValuesMarker
The NSMultipleValuesMarker indicates that more than one object is selected in the controller and the values for the requested key aren’t the same.
By default controllers return the NSMultipleValuesMarker only when the values for the requested key differ. For example, if the value for selection.name returns an array containing three strings—”Tony”, “Tony”, “Tony”—the string “Tony” is returned instead of the NSMultipleValuesMarker.
A collection controller can be configured—either programmatically using the method setAlwaysUsesMultipleValuesMarker: or by checking the Always uses multiple values marker checkbox in Interface Builder—such that it always returns NSMultipleValuesMarker when multiple items are selected, even if the values are equal.

Related

How do I access value of a selected <option> tag down 2 trees in a function?

PizzaBuilder1.js
Ingredients.js
Bases.js
PizzaBuilder2.js
PizzaBuilder3.js
I'll try to describe my issue in the least confusing way. So what I'm trying to achieve is create a function(pic4-PizzaBuilder2), where I compare the given key of this.state.ingredients.Bases (and other sub-objects, but that's not important for now) with value of selected option tag in Bases.js and when it matches, set the given value of that key to true. The hierarchy is like this: PizzaBuilder.js > Ingredients.js > Bases.js. I have already managed to match each option value with the key inside the object with the same name. However, what I'm still struggling with is how to access it in PizzaBuilder.js when the select option value I wanna compare it to is 2 trees down (see pic4-PizzaBuilder2, that is supposed to be const selectedOption, but I obviously still need to figure out how to access it). I'll be really grateful for any kind of advice.

Inflector not respecting custom rules

Using CakePHP 3.7.
I have added, at the bottom of config/bootstrap.php:
Inflector::rules('irregular', ['thesis' => 'theses']);
and actually, I've tried
Inflector::rules('irregular', ['theses' => 'thesis']);
just in case I had it backwards.
And in a cell I am trying to use:
use Cake\Utility\Inflector;
$singular_and_plural = [Inflector::singularize($base_name), $base_name];
The result for singularizing the word "thesis" is "thesiss".
Can anyone point out what's wrong, here?
The first form is the correct one, the key is the singular value, and the value the plural value.
That being said, what you're showing here is incorrect/problematic usage of Inflector::singularize(), as you're passing a value to it that already is singular, doing that often gives you unexpected/wrong results. You could open an issue ticket in such cases, sometimes this can be fixed in the core, but often times it's simply not possible as it would conflict with existing, required rules.
It should also be noted that CakePHP can handle thesis/theses out of the box already, it has singular/plural rules that match that. Make sure that you are passing in the expected values, and that you don't have additional custom rules that may interfer with what you're trying to inflect.

Get selected values in a checkbox group in xpages

I have a checkbox group and I am trying to get the values ​​selected via SSJS, but so far I have not been successful. I've tried several syntaxes, such as:
document1.getItemValueArray ("nameField")
and
getComponent ("nameField") getSelectedValues ​​();
Does anyone know a way to get the selected values ​​from a checkbox group?
document1.getFirstItem("nameField").getValues() may be what you want. If it's one value, it will be a string, not a Vector, which may be a problem with getItemValueArray().
With ODA (OpenNTF Domino API), we extended the getItemValue() method to take a second parameter and cast the result to that kind of object. That has a big benefit for this kind of scenario, allowing getItemValue("nameField", ArrayList.class) to always return an ArrayList even for a single value, plus ArrayList is a much better and more modern Java (so relevant also for SSJS) construct than a Vector.

What is the difference between ObservableMap and ObservableArray in mobx

As per the documentation,
observable.map(values?) creates a dynamic keyed observable map.
Observable maps are very useful if you don't want to react just to the
change of a specific entry, but also to the addition or removal of
entries.
I may be the only one who doesn't understand the difference between these two mobx observable types. Even the doc says map can track addition or removal, following array also notifies the console by autorun when a new value is pushed into the array. So what is the real difference between the two?
window.q = observable([1,2,3]);
autorun(()=>{console.log(q[0]);})
q.push(32)
The difference is in the methods you use to interact with them. Think of one as an array, and the other as a map. Arrays stores indices, maps store keys and values.

AngularJS arrays, proto and .length - Why can't i get a valid number?

Sometimes you need to ng-if or ng-show an item in html based on some choices made earlier. One of these for me is "Additional Item". You can enter one set of information, and also if you want, an additional set. This creates an array of 2 similar objects. With this setup, you can only have 1 or 2 objects in this array. (important, since the scope of this question needs to be limited this way)
I want to ng-show an html directive based on "myItemsArray.length > 1". Since the array can (read should) only be 1 or 2 in length (not 0), this should work. However, it does not, because AngularJS seems to be adding an item "proto" to the array which adds to the count. See the image.
The problem is, proto makes the array length equal 2. I am not going to just look for length > 2 because i really don't know if i can count on proto always being there, and i just think thats bad practice anyway.
Also, i know there are MANY other ways of doing this (setting a boolean, or using another var to indicate etc, but i really just want to work with count of items in the array because "business logic"..
EDIT:
After doing a little debugging, i'm seeing that i have an array of "Object, undefined". How is this even possible :)
Some search lead me to this. Why are some values ​​in my array undefined
EDIT:
Seems that using a delete may cause this problem

Resources