NSTextView defies intent of xibs with default attributes for quote, dash substitution

Originator:jalkut
Number:rdar://19970297 Date Originated:26-Feb-2015 11:54 AM
Status:Open Resolved:
Product:OS X Product Version:
Classification: Reproducible:
 
Summary:
An NSTextView that is unarchived from a xib will have settings including e.g. dash substitution and smart quote substitution enabled by default, even though they were explicitly unchecked in the Interface Builder UI.

I'm not sure whether the bug here lies in Xcode's assumptions about AppKit defaults, or in AppKit's assumption that missing values in a xib should imply "default" values from NSTextView.

The problem occurs because Interface Builder saves the attributes for an NSTextView in such a way that unchecking a box for e.g. smart quotes simply removes the attribute entirely from the resulting XML. The following text view has been configured in Xcode to have the smart quotes and smart dashes turned of, but notice there are no "NO" attributes:

<textView importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="zb0-g3-xCb">

Previously this wasn't a problem, and I don't know when it became a problem but I suspect that starting in 10.10 AppKit changed the default behavior for NSTextView such that some of these attributes, including smart quotes, should be turned on by default. I also suspect that a "linked on or after" check was included for this so that the default only applies if the app was build with a certain SDK or higher (the problem doesn't affect my apps built on older SDKs).

I think the solutions could include:

1. Interface Builder should write out attributes with explicit "NO" values corresponding to the unchecked boxes in the UI.

2. AppKit should assume, for the sake of decoding coded objects from xibs at least, the absence of a key value for many of these options should imply a NO setting.

In any case I think we can agree that a checkbox being checked "off" in Interface Builder needs to end up in causing the runtime NSTextView to have that option disabled by default.

The attached project shows a trivial example of a new app created in Xcode to include a single NSTextView, whose smart dashes and smart quotes were then turned off. The result at runtime is a text view whose smart dashes and smart quotes are in fact enabled.

Steps to Reproduce:


Expected Results:


Actual Results:


Version:
10.10.3 (14D72i)
Version 6.3 (6D520o)

Unfortunately it is not trivial for me to downgrade to or test on 10.10.2 or earlier at this time.


Notes:


Configuration:


Attachments:
'TestAutomaticSubstition.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!