Skip to content

Commit a230b5d

Browse files
authored
Rename methods to avoid ObjC KVC collisions. (protocolbuffers#1699)
Note: Breaking API change on the Dictionary classes. The numeric value classes were using "Value" in the naming, but this silently collided with the KVC category on NSObject; meaning KVC code could break up a keypath and call these selectors with the wrong types leading to crashes (even though the code all would compile cleanly). - Rename the methods to use the "type" instead of literal "Value". - Update all the impls and tests. - Enable the warning that will catch issues like this in the future. Fixes protocolbuffers#1616
1 parent 1a5333b commit a230b5d

14 files changed

+7448
-7325
lines changed

objectivec/GPBDictionary.h

+588-475
Large diffs are not rendered by default.

objectivec/GPBDictionary.m

+939-937
Large diffs are not rendered by default.

objectivec/GPBProtocolBuffers.m

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
// If you want to build protocol buffers in your own project without adding the
3232
// project dependency, you can just add this file.
3333

34+
35+
// This warning seems to treat code differently when it is #imported than when
36+
// it is inline in the file. GPBDictionary.m compiles cleanly in other targets,
37+
// but when #imported here it triggers a bunch of warnings that don't make
38+
// much sense, and don't trigger when compiled directly. So we shut off the
39+
// warnings here.
40+
#pragma clang diagnostic ignored "-Wnullability-completeness"
41+
3442
#import "GPBArray.m"
3543
#import "GPBCodedInputStream.m"
3644
#import "GPBCodedOutputStream.m"

objectivec/Tests/GPBDictionaryTests+Bool.m

+510-510
Large diffs are not rendered by default.

objectivec/Tests/GPBDictionaryTests+Int32.m

+1,022-1,022
Large diffs are not rendered by default.

objectivec/Tests/GPBDictionaryTests+Int64.m

+1,022-1,022
Large diffs are not rendered by default.

objectivec/Tests/GPBDictionaryTests+String.m

+1,018-1,018
Large diffs are not rendered by default.

objectivec/Tests/GPBDictionaryTests+UInt32.m

+1,022-1,022
Large diffs are not rendered by default.

objectivec/Tests/GPBDictionaryTests+UInt64.m

+1,022-1,022
Large diffs are not rendered by default.

objectivec/Tests/GPBDictionaryTests.pddm

+214-214
Large diffs are not rendered by default.

objectivec/Tests/GPBMessageTests+Serialization.m

+44-44
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ - (void)testMap_StandardWireFormat {
987987
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
988988
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
989989
int32_t val = 666;
990-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
990+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
991991
XCTAssertEqual(val, 1);
992992

993993
[msg release];
@@ -1001,7 +1001,7 @@ - (void)testMap_UnorderedWireFormat {
10011001
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
10021002
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
10031003
int32_t val = 666;
1004-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
1004+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
10051005
XCTAssertEqual(val, 1);
10061006

10071007
[msg release];
@@ -1015,7 +1015,7 @@ - (void)testMap_DuplicatedKeyWireFormat {
10151015
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
10161016
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
10171017
int32_t val = 666;
1018-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
1018+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
10191019
XCTAssertEqual(val, 1);
10201020

10211021
[msg release];
@@ -1029,7 +1029,7 @@ - (void)testMap_DuplicatedValueWireFormat {
10291029
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
10301030
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
10311031
int32_t val = 666;
1032-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
1032+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
10331033
XCTAssertEqual(val, 2);
10341034

10351035
[msg release];
@@ -1043,7 +1043,7 @@ - (void)testMap_MissedKeyWireFormat {
10431043
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
10441044
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
10451045
int32_t val = 666;
1046-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:0 value:&val]);
1046+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:0]);
10471047
XCTAssertEqual(val, 1);
10481048

10491049
[msg release];
@@ -1057,7 +1057,7 @@ - (void)testMap_MissedValueWireFormat {
10571057
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
10581058
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
10591059
int32_t val = 666;
1060-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:1 value:&val]);
1060+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:1]);
10611061
XCTAssertEqual(val, 0);
10621062

10631063
[msg release];
@@ -1071,7 +1071,7 @@ - (void)testMap_UnknownFieldWireFormat {
10711071
TestMap *msg = [[TestMap alloc] initWithData:data error:NULL];
10721072
XCTAssertEqual(msg.mapInt32Int32.count, 1U);
10731073
int32_t val = 666;
1074-
XCTAssertTrue([msg.mapInt32Int32 valueForKey:2 value:&val]);
1074+
XCTAssertTrue([msg.mapInt32Int32 getInt32:&val forKey:2]);
10751075
XCTAssertEqual(val, 3);
10761076

10771077
[msg release];
@@ -1098,17 +1098,17 @@ - (void)testMap_Proto2UnknownEnum {
10981098
dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
10991099
orig.unknownMapField = [GPBInt32EnumDictionary
11001100
dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
1101-
[orig.knownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
1102-
forKey:0];
1103-
[orig.unknownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
1104-
forKey:0];
1101+
[orig.knownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
1102+
forKey:0];
1103+
[orig.unknownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
1104+
forKey:0];
11051105

11061106
NSData *data = [orig data];
11071107
XCTAssertNotNil(data);
11081108
TestEnumMap *msg1 = [TestEnumMap parseFromData:data error:NULL];
11091109
XCTAssertEqual(msg1.knownMapField.count, 1U);
11101110
int32_t val = -1;
1111-
XCTAssertTrue([msg1.knownMapField valueForKey:0 value:&val]);
1111+
XCTAssertTrue([msg1.knownMapField getEnum:&val forKey:0]);
11121112
XCTAssertEqual(val, Proto2MapEnum_Proto2MapEnumFoo);
11131113
XCTAssertEqual(msg1.unknownFields.countOfFields, 1U);
11141114

@@ -1117,11 +1117,11 @@ - (void)testMap_Proto2UnknownEnum {
11171117
[TestEnumMapPlusExtra parseFromData:data error:NULL];
11181118
val = -1;
11191119
XCTAssertEqual(msg2.knownMapField.count, 1U);
1120-
XCTAssertTrue([msg2.knownMapField valueForKey:0 value:&val]);
1120+
XCTAssertTrue([msg2.knownMapField getEnum:&val forKey:0]);
11211121
XCTAssertEqual(val, Proto2MapEnumPlusExtra_EProto2MapEnumFoo);
11221122
val = -1;
11231123
XCTAssertEqual(msg2.unknownMapField.count, 1U);
1124-
XCTAssertTrue([msg2.unknownMapField valueForKey:0 value:&val]);
1124+
XCTAssertTrue([msg2.unknownMapField getEnum:&val forKey:0]);
11251125
XCTAssertEqual(val, Proto2MapEnumPlusExtra_EProto2MapEnumExtra);
11261126
XCTAssertEqual(msg2.unknownFields.countOfFields, 0U);
11271127

@@ -1137,32 +1137,32 @@ - (void)testProto2MapRoundTripping {
11371137

11381138
// Key/Value data should result in different byte lengths on wire to ensure
11391139
// everything is right.
1140-
[msg.mapInt32Int32 setValue:1000 forKey:200];
1141-
[msg.mapInt32Int32 setValue:101 forKey:2001];
1142-
[msg.mapInt64Int64 setValue:1002 forKey:202];
1143-
[msg.mapInt64Int64 setValue:103 forKey:2003];
1144-
[msg.mapUint32Uint32 setValue:1004 forKey:204];
1145-
[msg.mapUint32Uint32 setValue:105 forKey:2005];
1146-
[msg.mapUint64Uint64 setValue:1006 forKey:206];
1147-
[msg.mapUint64Uint64 setValue:107 forKey:2007];
1148-
[msg.mapSint32Sint32 setValue:1008 forKey:208];
1149-
[msg.mapSint32Sint32 setValue:109 forKey:2009];
1150-
[msg.mapSint64Sint64 setValue:1010 forKey:210];
1151-
[msg.mapSint64Sint64 setValue:111 forKey:2011];
1152-
[msg.mapFixed32Fixed32 setValue:1012 forKey:212];
1153-
[msg.mapFixed32Fixed32 setValue:113 forKey:2013];
1154-
[msg.mapFixed64Fixed64 setValue:1014 forKey:214];
1155-
[msg.mapFixed64Fixed64 setValue:115 forKey:2015];
1156-
[msg.mapSfixed32Sfixed32 setValue:1016 forKey:216];
1157-
[msg.mapSfixed32Sfixed32 setValue:117 forKey:2017];
1158-
[msg.mapSfixed64Sfixed64 setValue:1018 forKey:218];
1159-
[msg.mapSfixed64Sfixed64 setValue:119 forKey:2019];
1160-
[msg.mapInt32Float setValue:1020.f forKey:220];
1161-
[msg.mapInt32Float setValue:121.f forKey:2021];
1162-
[msg.mapInt32Double setValue:1022. forKey:222];
1163-
[msg.mapInt32Double setValue:123. forKey:2023];
1164-
[msg.mapBoolBool setValue:false forKey:true];
1165-
[msg.mapBoolBool setValue:true forKey:false];
1140+
[msg.mapInt32Int32 setInt32:1000 forKey:200];
1141+
[msg.mapInt32Int32 setInt32:101 forKey:2001];
1142+
[msg.mapInt64Int64 setInt64:1002 forKey:202];
1143+
[msg.mapInt64Int64 setInt64:103 forKey:2003];
1144+
[msg.mapUint32Uint32 setUInt32:1004 forKey:204];
1145+
[msg.mapUint32Uint32 setUInt32:105 forKey:2005];
1146+
[msg.mapUint64Uint64 setUInt64:1006 forKey:206];
1147+
[msg.mapUint64Uint64 setUInt64:107 forKey:2007];
1148+
[msg.mapSint32Sint32 setInt32:1008 forKey:208];
1149+
[msg.mapSint32Sint32 setInt32:109 forKey:2009];
1150+
[msg.mapSint64Sint64 setInt64:1010 forKey:210];
1151+
[msg.mapSint64Sint64 setInt64:111 forKey:2011];
1152+
[msg.mapFixed32Fixed32 setUInt32:1012 forKey:212];
1153+
[msg.mapFixed32Fixed32 setUInt32:113 forKey:2013];
1154+
[msg.mapFixed64Fixed64 setUInt64:1014 forKey:214];
1155+
[msg.mapFixed64Fixed64 setUInt64:115 forKey:2015];
1156+
[msg.mapSfixed32Sfixed32 setInt32:1016 forKey:216];
1157+
[msg.mapSfixed32Sfixed32 setInt32:117 forKey:2017];
1158+
[msg.mapSfixed64Sfixed64 setInt64:1018 forKey:218];
1159+
[msg.mapSfixed64Sfixed64 setInt64:119 forKey:2019];
1160+
[msg.mapInt32Float setFloat:1020.f forKey:220];
1161+
[msg.mapInt32Float setFloat:121.f forKey:2021];
1162+
[msg.mapInt32Double setDouble:1022. forKey:222];
1163+
[msg.mapInt32Double setDouble:123. forKey:2023];
1164+
[msg.mapBoolBool setBool:false forKey:true];
1165+
[msg.mapBoolBool setBool:true forKey:false];
11661166
msg.mapStringString[@"224"] = @"1024";
11671167
msg.mapStringString[@"2025"] = @"125";
11681168
msg.mapStringBytes[@"226"] = DataFromCStr("1026");
@@ -1171,12 +1171,12 @@ - (void)testProto2MapRoundTripping {
11711171
val1.optionalInt32 = 1028;
11721172
Message2 *val2 = [[Message2 alloc] init];
11731173
val2.optionalInt32 = 129;
1174-
[msg.mapStringMessage setValue:val1 forKey:@"228"];
1175-
[msg.mapStringMessage setValue:val2 forKey:@"2029"];
1174+
[msg.mapStringMessage setObject:val1 forKey:@"228"];
1175+
[msg.mapStringMessage setObject:val2 forKey:@"2029"];
11761176
[msg.mapInt32Bytes setObject:DataFromCStr("1030 bytes") forKey:230];
11771177
[msg.mapInt32Bytes setObject:DataFromCStr("131") forKey:2031];
1178-
[msg.mapInt32Enum setValue:Message2_Enum_Bar forKey:232];
1179-
[msg.mapInt32Enum setValue:Message2_Enum_Baz forKey:2033];
1178+
[msg.mapInt32Enum setEnum:Message2_Enum_Bar forKey:232];
1179+
[msg.mapInt32Enum setEnum:Message2_Enum_Baz forKey:2033];
11801180
Message2 *val3 = [[Message2 alloc] init];
11811181
val3.optionalInt32 = 1034;
11821182
Message2 *val4 = [[Message2 alloc] init];

objectivec/Tests/GPBMessageTests.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ - (void)testDefaultingMaps {
11711171
XCTAssertFalse([message2.a hasA]);
11721172

11731173
// But adding an element to the map should.
1174-
[message.a.a.iToI setValue:100 forKey:200];
1174+
[message.a.a.iToI setInt32:100 forKey:200];
11751175
XCTAssertTrue([message hasA]);
11761176
XCTAssertTrue([message.a hasA]);
11771177
XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
@@ -1190,7 +1190,7 @@ - (void)testAutocreatedMapShared {
11901190
message1a.a.iToI = message1b.a.iToI;
11911191
XCTAssertTrue([message1a hasA]);
11921192
XCTAssertFalse([message1b hasA]);
1193-
[message1a.a.iToI setValue:1 forKey:2];
1193+
[message1a.a.iToI setInt32:1 forKey:2];
11941194
XCTAssertTrue([message1a hasA]);
11951195
XCTAssertTrue([message1b hasA]);
11961196
XCTAssertEqual(message1a.a.iToI, message1b.a.iToI);
@@ -1224,7 +1224,7 @@ - (void)testAutocreatedMapCopy {
12241224
// with different objects that are equal).
12251225
TestRecursiveMessageWithRepeatedField *message3 =
12261226
[TestRecursiveMessageWithRepeatedField message];
1227-
message3.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:10 forKey:20];
1227+
message3.iToI = [GPBInt32Int32Dictionary dictionaryWithInt32:10 forKey:20];
12281228
message3.strToStr =
12291229
[NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
12301230
XCTAssertNotNil(message.iToI);
@@ -1292,7 +1292,7 @@ - (void)testReplaceAutocreatedMap {
12921292
XCTAssertFalse([message hasA]);
12931293
GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
12941294
XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
1295-
message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:6 forKey:7];
1295+
message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithInt32:6 forKey:7];
12961296
XCTAssertTrue([message hasA]);
12971297
XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
12981298
XCTAssertNil(iToI->_autocreator);

objectivec/Tests/GPBSwiftTests.swift

+20-20
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class GPBBridgeTests: XCTestCase {
5353
msg.repeatedStringArray.addObject("pqr")
5454
msg.repeatedEnumArray.addValue(Message2_Enum.Bar.rawValue)
5555
msg.repeatedEnumArray.addValue(Message2_Enum.Baz.rawValue)
56-
msg.mapInt32Int32.setValue(400, forKey:500)
57-
msg.mapInt32Int32.setValue(401, forKey:501)
56+
msg.mapInt32Int32.setInt32(400, forKey:500)
57+
msg.mapInt32Int32.setInt32(401, forKey:501)
5858
msg.mapStringString.setObject("foo", forKey:"bar")
5959
msg.mapStringString.setObject("abc", forKey:"xyz")
60-
msg.mapInt32Enum.setValue(Message2_Enum.Bar.rawValue, forKey:600)
61-
msg.mapInt32Enum.setValue(Message2_Enum.Baz.rawValue, forKey:601)
60+
msg.mapInt32Enum.setEnum(Message2_Enum.Bar.rawValue, forKey:600)
61+
msg.mapInt32Enum.setEnum(Message2_Enum.Baz.rawValue, forKey:601)
6262

6363
// Check has*.
6464
XCTAssertTrue(msg.hasOptionalInt32)
@@ -90,18 +90,18 @@ class GPBBridgeTests: XCTestCase {
9090
XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message2_Enum.Baz.rawValue)
9191
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
9292
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
93-
var intValue: Int32 = 0;
94-
XCTAssertTrue(msg.mapInt32Int32.valueForKey(500, value:&intValue))
93+
var intValue: Int32 = 0
94+
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 500))
9595
XCTAssertEqual(intValue, Int32(400))
96-
XCTAssertTrue(msg.mapInt32Int32.valueForKey(501, value:&intValue))
96+
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 501))
9797
XCTAssertEqual(intValue, Int32(401))
9898
XCTAssertEqual(msg.mapStringString.count, Int(2))
9999
XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
100100
XCTAssertEqual(msg.mapStringString.objectForKey("xyz") as? String, "abc")
101101
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
102-
XCTAssertTrue(msg.mapInt32Enum.valueForKey(600, value:&intValue))
102+
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
103103
XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
104-
XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, value:&intValue))
104+
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
105105
XCTAssertEqual(intValue, Message2_Enum.Baz.rawValue)
106106

107107
// Clearing a string with nil.
@@ -151,11 +151,11 @@ class GPBBridgeTests: XCTestCase {
151151
msg.repeatedEnumArray.addValue(Message3_Enum.Bar.rawValue)
152152
msg.repeatedEnumArray.addRawValue(666)
153153
SetMessage3_OptionalEnum_RawValue(msg2, 666)
154-
msg.mapInt32Int32.setValue(400, forKey:500)
155-
msg.mapInt32Int32.setValue(401, forKey:501)
154+
msg.mapInt32Int32.setInt32(400, forKey:500)
155+
msg.mapInt32Int32.setInt32(401, forKey:501)
156156
msg.mapStringString.setObject("foo", forKey:"bar")
157157
msg.mapStringString.setObject("abc", forKey:"xyz")
158-
msg.mapInt32Enum.setValue(Message2_Enum.Bar.rawValue, forKey:600)
158+
msg.mapInt32Enum.setEnum(Message2_Enum.Bar.rawValue, forKey:600)
159159
// "proto3" syntax lets enum get unknown values.
160160
msg.mapInt32Enum.setRawValue(666, forKey:601)
161161

@@ -183,20 +183,20 @@ class GPBBridgeTests: XCTestCase {
183183
XCTAssertEqual(msg2.optionalEnum, Message3_Enum.GPBUnrecognizedEnumeratorValue)
184184
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Int32(666))
185185
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
186-
var intValue: Int32 = 0;
187-
XCTAssertTrue(msg.mapInt32Int32.valueForKey(500, value:&intValue))
186+
var intValue: Int32 = 0
187+
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:500))
188188
XCTAssertEqual(intValue, Int32(400))
189-
XCTAssertTrue(msg.mapInt32Int32.valueForKey(501, value:&intValue))
189+
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:501))
190190
XCTAssertEqual(intValue, Int32(401))
191191
XCTAssertEqual(msg.mapStringString.count, Int(2))
192192
XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
193193
XCTAssertEqual(msg.mapStringString.objectForKey("xyz") as? String, "abc")
194194
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
195-
XCTAssertTrue(msg.mapInt32Enum.valueForKey(600, value:&intValue))
195+
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
196196
XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
197-
XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, value:&intValue))
197+
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
198198
XCTAssertEqual(intValue, Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
199-
XCTAssertTrue(msg.mapInt32Enum.valueForKey(601, rawValue:&intValue))
199+
XCTAssertTrue(msg.mapInt32Enum.getRawValue(&intValue, forKey:601))
200200
XCTAssertEqual(intValue, 666)
201201

202202
// Clearing a string with nil.
@@ -439,8 +439,8 @@ class GPBBridgeTests: XCTestCase {
439439
msg.optionalGroup.a = 102
440440
msg.repeatedStringArray.addObject("abc")
441441
msg.repeatedStringArray.addObject("def")
442-
msg.mapInt32Int32.setValue(200, forKey:300)
443-
msg.mapInt32Int32.setValue(201, forKey:201)
442+
msg.mapInt32Int32.setInt32(200, forKey:300)
443+
msg.mapInt32Int32.setInt32(201, forKey:201)
444444
msg.mapStringString.setObject("foo", forKey:"bar")
445445
msg.mapStringString.setObject("abc", forKey:"xyz")
446446

objectivec/Tests/GPBTestUtilities.m

+15-15
Original file line numberDiff line numberDiff line change
@@ -1089,19 +1089,19 @@ - (void)setAllExtensions:(TestAllExtensions *)message
10891089

10901090
- (void)setAllMapFields:(TestMap *)message numEntries:(uint32_t)count {
10911091
for (uint32_t i = 0; i < count; i++) {
1092-
[message.mapInt32Int32 setValue:(i + 1) forKey:100 + i * 100];
1093-
[message.mapInt64Int64 setValue:(i + 1) forKey:101 + i * 100];
1094-
[message.mapUint32Uint32 setValue:(i + 1) forKey:102 + i * 100];
1095-
[message.mapUint64Uint64 setValue:(i + 1) forKey:103 + i * 100];
1096-
[message.mapSint32Sint32 setValue:(i + 1) forKey:104 + i * 100];
1097-
[message.mapSint64Sint64 setValue:(i + 1) forKey:105 + i * 100];
1098-
[message.mapFixed32Fixed32 setValue:(i + 1) forKey:106 + i * 100];
1099-
[message.mapFixed64Fixed64 setValue:(i + 1) forKey:107 + i * 100];
1100-
[message.mapSfixed32Sfixed32 setValue:(i + 1) forKey:108 + i * 100];
1101-
[message.mapSfixed64Sfixed64 setValue:(i + 1) forKey:109 + i * 100];
1102-
[message.mapInt32Float setValue:(i + 1) forKey:110 + i * 100];
1103-
[message.mapInt32Double setValue:(i + 1) forKey:111 + i * 100];
1104-
[message.mapBoolBool setValue:((i % 2) == 1) forKey:((i % 2) == 0)];
1092+
[message.mapInt32Int32 setInt32:(i + 1) forKey:100 + i * 100];
1093+
[message.mapInt64Int64 setInt64:(i + 1) forKey:101 + i * 100];
1094+
[message.mapUint32Uint32 setUInt32:(i + 1) forKey:102 + i * 100];
1095+
[message.mapUint64Uint64 setUInt64:(i + 1) forKey:103 + i * 100];
1096+
[message.mapSint32Sint32 setInt32:(i + 1) forKey:104 + i * 100];
1097+
[message.mapSint64Sint64 setInt64:(i + 1) forKey:105 + i * 100];
1098+
[message.mapFixed32Fixed32 setUInt32:(i + 1) forKey:106 + i * 100];
1099+
[message.mapFixed64Fixed64 setUInt64:(i + 1) forKey:107 + i * 100];
1100+
[message.mapSfixed32Sfixed32 setInt32:(i + 1) forKey:108 + i * 100];
1101+
[message.mapSfixed64Sfixed64 setInt64:(i + 1) forKey:109 + i * 100];
1102+
[message.mapInt32Float setFloat:(i + 1) forKey:110 + i * 100];
1103+
[message.mapInt32Double setDouble:(i + 1) forKey:111 + i * 100];
1104+
[message.mapBoolBool setBool:((i % 2) == 1) forKey:((i % 2) == 0)];
11051105

11061106
NSString *keyStr = [[NSString alloc] initWithFormat:@"%d", 112 + i * 100];
11071107
NSString *dataStr = [[NSString alloc] initWithFormat:@"%d", i + 1];
@@ -1114,8 +1114,8 @@ - (void)setAllMapFields:(TestMap *)message numEntries:(uint32_t)count {
11141114
[data release];
11151115

11161116
[message.mapInt32Enum
1117-
setValue:(i % 2) ? MapEnum_MapEnumBar : MapEnum_MapEnumBaz
1118-
forKey:114 + i * 100];
1117+
setEnum:(i % 2) ? MapEnum_MapEnumBar : MapEnum_MapEnumBaz
1118+
forKey:114 + i * 100];
11191119

11201120
ForeignMessage *subMsg = [[ForeignMessage alloc] init];
11211121
subMsg.c = i + 1;

0 commit comments

Comments
 (0)