Skip to content

Commit a3466cc

Browse files
Address review comments
1 parent adbde6c commit a3466cc

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/darwin/Framework/CHIP/MTRSetupPayload.h

+15-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef NS_ENUM(NSUInteger, MTROptionalQRCodeInfoType) {
5959
* setters has no effect.
6060
*/
6161
MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
62-
@interface MTROptionalQRCodeInfo : NSObject <NSCopying>
62+
@interface MTROptionalQRCodeInfo : NSObject /* <NSCopying> (see below) */
6363

6464
- (instancetype)initWithTag:(uint8_t)tag stringValue:(NSString *)value MTR_NEWLY_AVAILABLE;
6565
- (instancetype)initWithTag:(uint8_t)tag int32Value:(int32_t)value MTR_NEWLY_AVAILABLE;
@@ -72,7 +72,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
7272
* Tags in the range 0x00 - 0x7F are reserved for Matter-defined elements.
7373
* Vendor-specific elements must have tags in the range 0x80 - 0xFF.
7474
*/
75-
@property (nonatomic, readonly, assign) uint8_t tagNumber;
75+
@property (nonatomic, readonly, assign) uint8_t tagNumber MTR_NEWLY_AVAILABLE;
7676

7777
/**
7878
* The value held in this extension element,
@@ -88,6 +88,10 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
8888

8989
@end
9090

91+
MTR_NEWLY_AVAILABLE
92+
@interface MTROptionalQRCodeInfo () <NSCopying>
93+
@end
94+
9195
/**
9296
* A Matter Onboarding Payload.
9397
*
@@ -100,7 +104,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
100104
* from the underlying values
101105
*/
102106
MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
103-
@interface MTRSetupPayload : NSObject <NSCopying, NSSecureCoding>
107+
@interface MTRSetupPayload : NSObject <NSSecureCoding> /* also <NSCopying> (see below) */
104108

105109
/**
106110
* Initializes the payload object from the provide QR Code or Manual Pairing Code string.
@@ -153,23 +157,23 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
153157
/**
154158
* The list of Manufacturer-specific extension elements contained in the setup code. May be empty.
155159
*/
156-
@property (nonatomic, readonly, copy) NSArray<MTROptionalQRCodeInfo *> * vendorElements;
160+
@property (nonatomic, readonly, copy) NSArray<MTROptionalQRCodeInfo *> * vendorElements MTR_NEWLY_AVAILABLE;
157161

158162
/**
159163
Returns the Manufacturer-specific extension element with the specified tag, if any.
160164
*/
161-
- (nullable MTROptionalQRCodeInfo *)vendorElementWithTag:(uint8_t)tag;
165+
- (nullable MTROptionalQRCodeInfo *)vendorElementWithTag:(uint8_t)tag MTR_NEWLY_AVAILABLE;
162166

163167
/**
164168
* Removes the extension element with the specified tag, if any.
165169
*/
166-
- (void)removeVendorElementWithTag:(uint8_t)tag;
170+
- (void)removeVendorElementWithTag:(uint8_t)tag MTR_NEWLY_AVAILABLE;
167171

168172
/**
169173
* Adds or replaces a Manufacturer-specific extension element.
170174
* The element must have a tag in the vendor-specific range (0x80 - 0xFF).
171175
*/
172-
- (void)addOrReplaceVendorElement:(MTROptionalQRCodeInfo *)element;
176+
- (void)addOrReplaceVendorElement:(MTROptionalQRCodeInfo *)element MTR_NEWLY_AVAILABLE;
173177

174178
/**
175179
* Generate a random Matter-valid setup PIN.
@@ -215,6 +219,10 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
215219

216220
@end
217221

222+
MTR_NEWLY_AVAILABLE
223+
@interface MTRSetupPayload () <NSCopying>
224+
@end
225+
218226
@interface MTROptionalQRCodeInfo (Deprecated)
219227

220228
- (instancetype)init MTR_NEWLY_DEPRECATED("Please use -initWithTag:...value:");

src/darwin/Framework/CHIP/MTRSetupPayload.mm

+9-3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ - (MTROptionalQRCodeInfoType)type
8585
case chip::optionalQRCodeInfoTypeInt32:
8686
return MTROptionalQRCodeInfoTypeInt32;
8787
// No 'default:' so we get a warning if new types are added.
88+
// Note: isEqual: also switches over these types.
8889
// OptionalQRCodeInfo does not support these types
8990
case chip::optionalQRCodeInfoTypeInt64:
9091
case chip::optionalQRCodeInfoTypeUInt32:
@@ -129,9 +130,14 @@ - (BOOL)isEqual:(id)object
129130
MTROptionalQRCodeInfo * other = object;
130131
VerifyOrReturnValue(_info.tag == other->_info.tag, NO);
131132
VerifyOrReturnValue(_info.type == other->_info.type, NO);
132-
VerifyOrReturnValue(_info.int32 == other->_info.int32, NO);
133-
VerifyOrReturnValue(_info.data == other->_info.data, NO);
134-
return YES;
133+
switch (_info.type) {
134+
case chip::optionalQRCodeInfoTypeString:
135+
return _info.data == other->_info.data;
136+
case chip::optionalQRCodeInfoTypeInt32:
137+
return _info.int32 == other->_info.int32;
138+
default:
139+
return NO; // unreachable, type is checked in init
140+
}
135141
}
136142

137143
- (NSString *)description

0 commit comments

Comments
 (0)