KVO detection of changes to selection in NSOpenPanel

2015-07-20 Thread Jonathan Taylor
I’ve just noticed a glitch where my custom file preview box in an NSOpenPanel 
works fine on OS X 10.9.5 but does not get updated on 10.8.5. Specifically, I 
declare a dependency of my property on panel.filenames, panel.URL and 
panel.directoryURL (just to see if ANY of them fire), and none of them are 
getting prodded when the user changes the selected file/directory. Does anybody 
know if this is expected behaviour?

I did notice somewhere buried in here:
https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/#X10_9Notes
that it says (for OS X 10.9)
 Key Value Observation compliance was dramatically increased for public and 
 some private properties of actual, non sandboxed NSOpen and Save panels, 
 including keys affecting other values. For example, if the directory value 
 changes on a save panel, this will cause a KVO notification to be emitted for 
 the URL value as well as the directory value. Sandboxed NSOpen and Save 
 Panels do not have the same level of KVO compliance.

This does make me wonder if I should perhaps not be surprised that my use of 
keyPathsAffectingValueForKey is not going well, although nothing in that 
statement seems to specifically preclude what I am doing from working on 10.8. 
Does anyone know if there’s any hope of my KVO approach working? The 
alternative seems to be to implement a delegate method for 
panelSelectionDidChange. Would that be the sensible way to deal with this, or 
is there a third and better way I should be using?

Cheers
Jonny
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: KVO detection of changes to selection in NSOpenPanel

2015-07-20 Thread Kyle Sluder
On Mon, Jul 20, 2015, at 11:13 AM, Jonathan Taylor wrote:
 This does make me wonder if I should perhaps not be surprised that my use
 of keyPathsAffectingValueForKey is not going well, although nothing in
 that statement seems to specifically preclude what I am doing from
 working on 10.8. Does anyone know if there’s any hope of my KVO approach
 working?

No. If a property is not explicitly documented to be KVO-compliant, you
must assume that it isn't.

The alternative seems to be to implement a delegate method for
 panelSelectionDidChange. Would that be the sensible way to deal with
 this, or is there a third and better way I should be using?

It seems pretty straightforward to just implement the delegate method
regardless of OS version.

--Kyle Sluder

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com