We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6681af4 commit 257172dCopy full SHA for 257172d
Foundation/NSString.swift
@@ -457,7 +457,7 @@ extension NSString {
457
458
public var intValue: Int32 {
459
get {
460
- NSUnimplemented()
+ return NSScanner(string: _swiftObject).scanInt() ?? 0
461
}
462
463
TestFoundation/TestNSString.swift
@@ -24,6 +24,7 @@ class TestNSString : XCTestCase {
24
("test_boolValue", test_boolValue ),
25
("test_BridgeConstruction", test_BridgeConstruction ),
26
("test_integerValue", test_integerValue ),
27
+ ("test_intValue", test_intValue ),
28
("test_isEqualToStringWithSwiftString", test_isEqualToStringWithSwiftString ),
29
("test_isEqualToObjectWithNSString", test_isEqualToObjectWithNSString ),
30
("test_isNotEqualToObjectWithNSNumber", test_isNotEqualToObjectWithNSNumber ),
@@ -95,6 +96,14 @@ class TestNSString : XCTestCase {
95
96
XCTAssertEqual(string8.integerValue, 0)
97
98
99
+ func test_intValue() {
100
+ let string1: NSString = "2147483648"
101
+ XCTAssertEqual(string1.intValue, 2147483647)
102
+
103
+ let string2: NSString = "-2147483649"
104
+ XCTAssertEqual(string2.intValue, -2147483648)
105
+ }
106
107
func test_isEqualToStringWithSwiftString() {
108
let string: NSString = "literal"
109
let swiftString = "literal"
0 commit comments