Skip to content

Commit 5612c07

Browse files
authored
Merge pull request #1356 from BranchMetrics/SDK-2250
The original code used boolValue
2 parents 9eb07e2 + 1b03a81 commit 5612c07

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Branch-TestBed/Branch-SDK-Tests/NSMutableDictionaryBranchTests.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,24 +363,27 @@ - (void)testGetBooleanForKey {
363363
@"bool2" : @(0),
364364
@"bool3" : @"1", // valid bool
365365
@"bool4" : @"0", // valid bool
366-
@"bool5" : @"YES", // invalid bool, server expects a number. treated as false
367-
@"bool6" : @"NO", // invalid bool, server expects a number. treated as false
366+
@"bool5" : @"YES",
367+
@"bool6" : @"NO",
368368
@"bool7" : @(-1), // all non-zero numbers are true
369369
@"bool8" : @(1234), // all non-zero numbers are true
370-
@"bool9" : @[ ] // invalid bool, treated as false
371-
370+
@"bool9" : @[ ], // invalid bool, treated as false
371+
@"bool10": @"true",
372+
@"bool11": @"false"
372373
};
373374
NSMutableDictionary *dict = [tmp mutableCopy];
374375

375376
XCTAssertTrue([dict bnc_getBooleanForKey:@"bool1"]);
376377
XCTAssertFalse([dict bnc_getBooleanForKey:@"bool2"]);
377378
XCTAssertTrue([dict bnc_getBooleanForKey:@"bool3"]);
378379
XCTAssertFalse([dict bnc_getBooleanForKey:@"bool4"]);
379-
XCTAssertFalse([dict bnc_getBooleanForKey:@"bool5"]);
380+
XCTAssertTrue([dict bnc_getBooleanForKey:@"bool5"]);
380381
XCTAssertFalse([dict bnc_getBooleanForKey:@"bool6"]);
381382
XCTAssertTrue([dict bnc_getBooleanForKey:@"bool7"]);
382383
XCTAssertTrue([dict bnc_getBooleanForKey:@"bool8"]);
383384
XCTAssertFalse([dict bnc_getBooleanForKey:@"bool9"]);
385+
XCTAssertTrue([dict bnc_getBooleanForKey:@"bool10"]);
386+
XCTAssertFalse([dict bnc_getBooleanForKey:@"bool11"]);
384387
}
385388

386389
@end

Sources/BranchSDK/NSMutableDictionary+Branch.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ - (BOOL)bnc_getBooleanForKey:(NSString *)key {
192192
returnValue = [number boolValue];
193193
} else if ([tmp isKindOfClass:[NSString class]]) {
194194
NSString *numberAsString = (NSString *)tmp;
195-
returnValue = [numberAsString doubleValue];
195+
returnValue = [numberAsString boolValue];
196196
}
197197

198198
return returnValue;

0 commit comments

Comments
 (0)