Keep getting NSMultipleValuesMarker <MULTIPLE VALUES MARKER> on arrayController valueForKeyPath:

StackOverflow https://stackoverflow.com/questions/23273512

  •  09-07-2023
  •  | 
  •  

Question

This code works fine for single selections or multiple selections in the table with the same values for the selected objects.

NSNumber *currentValue = (NSNumber *)[mArrayController valueForKeyPath: mBindingKeyPath];

But if I have multiple selections with different values for the selected objects, I get this error and crash – which is correct because I do have multiple selections in my table. But of course I don't want to crash and instead get the selection as an array or how is it supposed to work?

2014-04-24 17:20:33.167 DC MacOSX[5746:303] -[_NSStateMarker floatValue]: unrecognized selector sent to instance 0x1006135a0
2014-04-24 17:20:33.168 DC MacOSX[5746:303] -[_NSStateMarker floatValue]: unrecognized selector sent to instance 0x1006135a0
2014-04-24 17:20:33.170 DC MacOSX[5746:303] (
0   CoreFoundation                      0x00007fff8b71bb06 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff850b03f0 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8b7b240a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3   CoreFoundation                      0x00007fff8b70a02e ___forwarding___ + 414
4   CoreFoundation                      0x00007fff8b709e18 _CF_forwarding_prep_0 + 232
5   Dreamcatcher MacOSX                 0x0000000100066199 -[CustomNSSliderJoystick1D mouseDragged:] + 434
6   AppKit                              0x00007fff89a60b81 -[NSWindow sendEvent:] + 8504

7   AppKit                              0x00007fff89a5c644 -[NSApplication sendEvent:] + 5761
Was it helpful?

Solution

Google: "NSArrayController class reference"

Find: selectedObjects:

The NSArrayController instance methods are what you're going to want to use to query the selection. The binding guarantees that the array controller is in a state that matches whatever you have bound it to, usually a view. But the whole point of binding it, is so that you can use NSArrayController methods to access that state.

This answer seems flippant -- let me google that for you -- but you're new, and especially with OSX APIs, you'll be referring to developer.apple.com class references all the time. AppKiDo and Dash are great tools to do that with.

You will also find isKindOfClass useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top