IBInspectable: Inspectables should support enum properties

Originator:daniel
Number:rdar://27243860 Date Originated:08-Jul-2016 01:49 PM
Status:Duplicate of 15505220 (Open) Resolved:13-Jul-2016 09:33 AM
Product:Developer Tools Product Version:Xcode-beta (8S128d)
Classification:Enhancement Reproducible:Not Applicable
 
Summary:
Clang has all the smarts it would need to power this, so it would be great if marking a property of an enum type as IBInspectable should translate the possible values of this enum to the options in an NSPopupButton in IB.

Steps to Reproduce:
1. Copy and paste the following code into a Swift file of some project:
public
class BigLoada: NSObject {
    public
    enum Track: Int {
        case AJourneyToReedham, FullRinse, Massif, ComeOnMySelector, TheBodyBuilder, TequilaFish, JacquesMalChance
    }

    @IBInspectable
    var favoriteTrack: Track
    @IBInspectable
    var bogusAttribute: String?

    public
    override init() {
        favoriteTrack = .ComeOnMySelector
        super.init()
    }
}

extension BigLoada.Track: CustomStringConvertible {
    public
    var description: String {
        switch self {
        case .AJourneyToReedham:
            return "A Journey To Reedham"
        case .FullRinse:
            return "Full Rinse"
        case .Massif:
            return "Massif"
        case .ComeOnMySelector:
            return "Come On my Selector"
        case .TheBodyBuilder:
            return "The Body Builder"
        case .TequilaFish:
            return "Tequila Fish"
        case .JacquesMalChance:
            return "Jacques Mal Chance"
        }
    }
}
2. Create a new xib or storyboard in this project, and instantiate a custom NSObject.
3. Set this instance’s class to BigLoada and open its property inspector.


Expected Results:
- There are two properties exposed on the “BigLoada” instance: An NSTextField labeled “Bogus Attribute”, and an NSPopUpButton labeled “Favorite Track”
- Ideally, the popup button has “Come On My Selector” preselected. (No selection at all/“Default” would be acceptable as well, though.)
- When clicking the popup button, you get all the enum cases listed in the order in which they occur in the type.
- Optionally, there is an additional “Default” option above a separator item followed by the possible enum cases.
- Ideally, the enum cases make use of the custom description, such that the popup resembles the track listing of Squarepusher’s “Big Loada” record.

Actual Results:
Only the “Bogus Attribute” property is exposed in IB at all.

Version:
Xcode-beta (8S128d), but any earlier version of Xcode will do, too.


Notes:
I am very well aware that there are existing radars for this already, and probably since WWDC 2014. But it would be so nice if this would actually be implemented!

Configuration:


Attachments:

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!