Swift中HomeKit配件分组(HMServiceGroup)(七)

如果想将一些服务组合在一起,方便以后时候,可以通过HMServiceGroup进行实现

  • 创建分组
        self.home.addServiceGroup(withName: "serviceGroup1") { (group, error) in
            if error == nil{
                print("创建分组成功")
            }else{
                print("创建分组失败")
            }
        }
 self.home.removeServiceGroup(<#T##group: HMServiceGroup##HMServiceGroup#>, completionHandler: <#T##(Error?) -> Void#>)//删除分组

添加服务

           groupService.addService(service) { (error) in
                //添加服务
            }
            groupService.removeService(<#T##service: HMService##HMService#>, completionHandler: <#T##(Error?) -> Void#>)//取消服务
原文地址:https://www.cnblogs.com/hualuoshuijia/p/12018189.html