欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Swift switch 你所不知道用法 switch case let accessory as HMAccessory

程序员文章站 2024-01-03 09:37:40
...

官方Demo

func append(object: AnyObject) {
        switch object {
            case let actionSet as HMActionSet:
                actionSets.append(actionSet)
                actionSets = actionSets.sortByTypeAndLocalizedName()

            case let accessory as HMAccessory:
                accessories.append(accessory)
                accessories = accessories.sortByLocalizedName()

            case let room as HMRoom:
                rooms.append(room)
                rooms = rooms.sortByLocalizedName()

            case let zone as HMZone:
                zones.append(zone)
                zones = zones.sortByLocalizedName()

            case let trigger as HMTrigger:
                triggers.append(trigger)
                triggers = triggers.sortByLocalizedName()

            case let serviceGroup as HMServiceGroup:
                serviceGroups.append(serviceGroup)
                serviceGroups = serviceGroups.sortByLocalizedName()

            default:
                break
        }
    }

Swift switch 你所不知道用法 switch case let accessory as HMAccessory

上一篇:

下一篇: