Xcode – NSTextView with Smart Quotes disabled, still replaces quotes

cocoamacosxcode

I have a NSTextView with the 'Smart Quotes' option disabled:

Smart Quotes disabled

However, if I were to type:

'hello world'

Into the textview, it instanly gets replaced with:

‘hello world’

(see how the single quotes have been replaced).

I thought disabling smart quotes would have taken care of this, but it does not seem to of helped. Any suggestions on how I can get these prettier quotes to go away?

Best Answer

You can disable smart quotes for your NSTextView with:

self.textView.automaticQuoteSubstitutionEnabled = NO;

Not setting the checkmark in the interface builder doesn't seem to work since OS X 10.9 Mavericks.

See NSTextView setAutomaticQuoteSubstitutionEnabled:

Also you can use this for a more detailed control over the text replacement.

self.textView.enabledTextCheckingTypes = 0;

See NSTextView setEnabledTextCheckingTypes:

Also in Mavericks there is smart quotes enabled by default in System Preferences → Keyboard → Text. You can disable this as a personal preference.

Related Topic