简体中文
简体中文
English
注册
登录
简体中文
简体中文
English
注册
登录
语言
简体中文
简体中文
English
注册
登录

如何监听到 ThingSmartHome 的对象 home 发生了切换?

更新时间2025-02-28 07:17:26
示例如下:
- (void)viewDidLoad {
[super viewDidLoad];
// 监听 家庭 是否发生切换
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(homeIdDidChangedTest) name:@"kThingTPNotificationHomeIdDidChanged" object:nil];
}
- (void)homeIdDidChangedTest {
NSLog(@"\n== 家庭发生了切换");
id<ThingFamilyProtocol> familyImpl = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingFamilyProtocol)];
ThingSmartHome *home = [ThingSmartHome homeWithHomeId:[familyImpl currentFamilyId]];
NSLog(@"\n== 当前家庭为: %@" , home.homeModel.name );
}

点击获取服务和帮助

帮助中心