skills/developer.tuya.com/managing-tuya-ios-device-list

managing-tuya-ios-device-list

Installation
SKILL.md

概述 {#description}

为涂鸦 IoT iOS ObjC App 构建「设备列表管理」模块。设备列表是 IoT App 的核心页面之一,需要展示当前家庭下的所有设备以及其他用户分享过来的设备,并支持常见的列表交互操作。

模块两大数据来源:

  1. 家庭设备列表 — 通过 getHomeDataWithSuccess:failure: 获取,ThingSmartDeviceModel.isShare == NO
  2. 共享设备列表 — 同样在 homeModel.deviceList 中,ThingSmartDeviceModel.isShare == YES

适用场景 {#scene}

已完成当前家庭管理模块,需要在首页/家庭页展示设备列表时使用。

Phase 1 — 家庭设备列表:监听 CurrentHomeDidChangeNotification,家庭切换时先清空两个数组再重新调用 getHomeDataWithSuccess:failure: 拉取完整快照;从 homeModel.deviceListisShare 分拣到 myDevicessharedDevices 两个数组;设置 home.delegate = self 并持有 self.currentHome 强引用;实现 ThingSmartHomeDelegate 回调(didAddDeivicedidRemoveDeivicedeviceInfoUpdate:device:dpsUpdate:homeDidUpdateSharedInfo:)。

Phase 2 — UITableView 多 Section 展示:Section 0 展示家庭设备,Section 1 展示共享设备(sharedDevices.count > 0 时才显示 section header);实现 updateEmptyState 控制空状态视图显示。

Installs
4
First Seen
May 28, 2026
managing-tuya-ios-device-list from developer.tuya.com