키-값 API는 기기, 회의실, 자동화 객체를 위한 새로운 맞춤 데이터 관리 API를 제공합니다. 맞춤 데이터의 수명 주기는 연결된 객체의 수명 주기로 엄격하게 범위가 지정됩니다. 예를 들어 회의실 객체와 연결된 맞춤 데이터('Lucy's room'과 같은)는 회의실 객체와 함께 자동으로 삭제, 이동 또는 전송 (구조 간)됩니다.
Swift API 변경사항은
CustomAppData
컨트롤러를 중심으로 하며 맞춤 애플리케이션
데이터가 속한 객체에 확장 프로그램을 제공하고 표준 만들기, 읽기, 업데이트, 삭제
(CRUD) 함수를 포함합니다.
기기 예시
guard let device = home.devices.first(where: { $0.name == deviceName }) else { return }
var response = try await device.customAppData[key]
print("Before: \(response)")
try await device.customAppData.update(key: key, value: value)
response = try await device.customAppData[key]
print("After: \(response)")
try await device.customAppData.delete(key)
회의실 예시
guard let room = home.rooms.first(where: { $0.name == roomName }) else { return }
try await room.customAppData.update(key: "nickname", value: "Lucy's Room")
let response = try await room.customAppData["nickname"]
try await room.customAppData.delete("nickname")
자동화 예시
guard let automation = home.automations.first(where: { $0.name == automationName }) else { return }
var response = try await automation.customAppData[key]
print("Before: \(response)")
try await automation.customAppData.update(key: key, value: value)
response = try await automation.customAppData[key]
print("After: \(response)")
try await automation.customAppData.delete(key)
제한사항
- 키는 최대 길이가 128인 유효한 UTF-8 문자열이어야 합니다. 키는 빈 문자열일 수 있습니다.
- 값은 최대 길이가 1024인 유효한 UTF-8 문자열이어야 합니다. 값은 빈 문자열일 수 있습니다.
- 각 객체는 10개의 키-값 쌍 행을 가질 수 있습니다.