Xcode 7.2 (7C62b): NSTextTab -description doesn't differentiate between Left, Justified, and Natural alignments

Originator:igeek1
Number:rdar://23641901 Date Originated:21-Nov-2015 12:30 PM
Status:Resolved Resolved:July 20 2017, 5:44 PM
Product:Developer Tools Product Version:Xcode 7.2 (7C62b)
Classification:UI/Usability Reproducible:Always
 
Summary:
NSTextTab’s -description implementation does not differentiate between Left, Justified, and Natural alignments, leading to developer confusion.

Steps to Reproduce:
1. Open the attached playground. It looks like this:

    import UIKit

    let left = NSTextTab(textAlignment: .Left, location: 20, options: [:])
    let right = NSTextTab(textAlignment: .Right, location: 20, options: [:])
    let center = NSTextTab(textAlignment: .Center, location: 20, options: [:])
    let justified = NSTextTab(textAlignment: .Justified, location: 20, options: [:])
    let natural = NSTextTab(textAlignment: .Natural, location: 20, options: [:])

    left.description // "20L"
    right.description // "20R"
    center.description // "20C"
    justified.description // "20L" <- unexpected
    natural.description // "20L" <- unexpected

2. Observe the output of the calls to -description, which I’ve included in the comments.

Expected Results:
They should be, in order:
20L
20R
20C
20J (L)
20N (L)

Or similar. The point is that Justified and Natural are differentiated from Left, even though they behave similarly to Left in left-to-right locales. I haven’t tested their behavior on RTL systems, but I assume they would reverse.

Actual Results:
Justified and Natural alignments are both expressed as 20L in this example. Going by -description alone, this can be very confusing. I was tripped up by this because I was writing a unit test to assert that a generated attributed string was equal to a known good control attributed string. The test was reporting that they were not equal, but their descriptions were identical. This is because the generated string used NSTextAlignmentNatural, and the control string used NSTextAlignmentLeft, but the descriptions were the same, so it was hard to tell where they differed.

Regression:
This affects both Xcode 7.1.1 and Xcode 7.2b4.

Notes:
Playground uploaded here: http://cl.ly/dsq2

Comments

Confirmed fixed on macOS 10.13 beta 3 running in both a macOS Playground and an iOS Playground 🎉

Apple Developer Relations

Please verify this issue with the macOS 10.13 beta and update your bug report at https://bugreport.apple.com/ with your results.

macOS 10.13 beta 3 (17A306f) https://developer.apple.com/download/ Posted Date: July 10th, 2017

If the issue persists and it's applicable to your bug report, please attach a new sysdiagnose captured in the latest build and attach it to the bug report.

macOS sysdiagnose Instructions: https://developer.apple.com/services-account/download?path=/OS_X/OS_X_Logs/sysdiagnose_Logging_Instructions.pdf


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!