Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

[ASControlNode] ASControlStateNormal disappears in Swift 3.0 #2278

@george-gw

Description

@george-gw

AsyncDisplayKit: master
Swift 3.0
Xcode: Version 8.0 (8A218a)

Using:
buttonNode.setBackgroundImage(image, for: .normal)
Error:
'normal' is unavailable: use [] to construct an empty option set

You can still get it to work without modifying ASDK by using:
buttonNode.setBackgroundImage(image, for: ASControlState())

While Xcode converts UIControlState's .normal to UIControlState() as well, .normal works just fine.

The reason I'm getting the error is that the generated swift code for ASControlState is:

public struct ASControlState : OptionSet {

    public init(rawValue: UInt)


    public static var highlighted: ASControlState { get } // used when ASControlNode isHighlighted is set

    public static var disabled: ASControlState { get }

    public static var selected: ASControlState { get } // used when ASControlNode isSelected is set

    public static var reserved: ASControlState { get } // flags reserved for internal framework use
}

There's no normal variable.
I believe it's because ASControlStateNormal has a value of 0, if you change the Objective-C code to:

typedef NS_OPTIONS(NSUInteger, ASControlState) {
    ASControlStateNormal       = 1 << 0,
    ASControlStateHighlighted  = 1 << 1,                  // used when ASControlNode isHighlighted is set
    ASControlStateDisabled     = 1 << 2,
    ASControlStateSelected     = 1 << 3,                  // used when ASControlNode isSelected is set
    ASControlStateReserved     = 0xFF000000               // flags reserved for internal framework use
};

Then you get the .normal option, but I'm not sure if that's a desired change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions