Skip to content

Commit 142d88b

Browse files
authored
Merge pull request #2128 from millenomi/nscoder-funnel-off
Parity: objectValue(…)
2 parents 0f18d1a + 4fcd3b2 commit 142d88b

9 files changed

+22
-40
lines changed

Foundation/DateComponentsFormatter.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,5 @@ open class DateComponentsFormatter : Formatter {
128128
Currently unimplemented, will be removed in a future seed.
129129
*/
130130
open var formattingContext: Context
131-
132-
/* DateComponentsFormatter currently only implements formatting, not parsing. Until it implements parsing, this will always return NO.
133-
*/
134-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
135-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
136-
open override func objectValue(_ string: String) throws -> Any? { return nil }
137131
}
138132

Foundation/DateFormatter.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ open class DateFormatter : Formatter {
4343

4444
open var formattingContext: Context = .unknown // default is NSFormattingContextUnknown
4545

46-
open func objectValue(_ string: String, range rangep: UnsafeMutablePointer<NSRange>) throws -> AnyObject? { NSUnimplemented() }
47-
46+
@available(*, unavailable, renamed: "date(from:)")
47+
func getObjectValue(_ obj: UnsafeMutablePointer<AnyObject?>?,
48+
for string: String,
49+
range rangep: UnsafeMutablePointer<NSRange>?) throws {
50+
NSUnsupported()
51+
}
52+
4853
open override func string(for obj: Any) -> String? {
4954
guard let date = obj as? Date else { return nil }
5055
return string(from: date)

Foundation/DateIntervalFormatter.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ open class DateIntervalFormatter: Formatter {
181181
return nil
182182
}
183183

184-
open override func objectValue(_ string: String) throws -> Any? {
185-
return nil
186-
}
187-
188184
open override func copy(with zone: NSZone? = nil) -> Any {
189185
return DateIntervalFormatter(cfFormatter: CFDateIntervalFormatterCreateCopy(nil, core))
190186
}

Foundation/EnergyFormatter.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ open class EnergyFormatter: Formatter {
173173
//Return the appropriate representation of the unit based on the selected unit style
174174
return unitString(fromValue: numberInUnit, unit: unitFromJoules)
175175
}
176-
177-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
178-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
179-
open override func objectValue(_ string: String) throws -> Any? { return nil }
180176

181177
/// Regions that use calories
182178
private static let caloriesRegions: Set<String> = ["en_US", "en_US_POSIX", "haw_US", "es_US", "chr_US", "en_GB", "kw_GB", "cy_GB", "gv_GB"]

Foundation/Formatter.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ open class Formatter : NSObject, NSCopying, NSCoding {
7373
return string(for: obj)
7474
}
7575

76-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
77-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
76+
@available(*, unavailable, message: "Use each formatter's class and instance methods instead.")
7877
open func objectValue(_ string: String) throws -> Any? {
79-
NSRequiresConcreteImplementation()
78+
NSUnsupported()
79+
}
80+
81+
@available(*, unavailable, message: "Use each formatter's class and instance methods instead.")
82+
func getObjectValue(_ obj: UnsafeMutablePointer<AnyObject?>?,
83+
for string: String,
84+
errorDescription error: UnsafeMutablePointer<NSString?>?) -> Bool {
85+
NSUnsupported()
8086
}
8187
}
8288

Foundation/LengthFormatter.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@ open class LengthFormatter : Formatter {
152152
}
153153
}
154154

155-
156-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
157-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
158-
open override func objectValue(_ string: String) throws -> Any? { return nil }
159-
160-
161155
/// Maps LengthFormatter.Unit enum to UnitLength class. Used for measurement conversion.
162156
private static let unitLength: [Unit:UnitLength] = [.millimeter:.millimeters,
163157
.centimeter:.centimeters,

Foundation/MassFormatter.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ open class MassFormatter : Formatter {
121121
return unitString(fromValue: numberInUnit, unit: unitFromKilograms)
122122
}
123123

124-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
125-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
126-
open override func objectValue(_ string: String) throws -> Any? { return nil }
127-
128-
129124
// MARK: - Private
130125

131126
/// This method selects the appropriate unit based on the formatter’s locale,

Foundation/NumberFormatter.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ open class NumberFormatter : Formatter {
7575

7676
open var formattingContext: Context = .unknown // default is NSFormattingContextUnknown
7777

78-
// Report the used range of the string and an NSError, in addition to the usual stuff from Formatter
79-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
80-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
81-
open func objectValue(_ string: String, range: inout NSRange) throws -> Any? { NSUnimplemented() }
78+
@available(*, unavailable, renamed: "number(from:)")
79+
func getObjectValue(_ obj: UnsafeMutablePointer<AnyObject?>?,
80+
for string: String,
81+
range rangep: UnsafeMutablePointer<NSRange>?) throws {
82+
NSUnsupported()
83+
}
8284

8385
open override func string(for obj: Any) -> String? {
8486
//we need to allow Swift's numeric types here - Int, Double et al.

Foundation/PersonNameComponentsFormatter.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ open class PersonNameComponentsFormatter : Formatter {
6868
open func annotatedString(from components: PersonNameComponents) -> NSAttributedString { NSUnimplemented() }
6969

7070
open func personNameComponents(from string: String) -> PersonNameComponents? { NSUnimplemented() }
71-
72-
/* PersonNameComponentsFormatter currently only implements formatting, not parsing. Until it implements parsing, this will always return NO.
73-
*/
74-
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative
75-
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
76-
open override func objectValue(_ string: String) throws -> Any? { return nil }
7771
}
7872

7973
// Attributed String identifier key string

0 commit comments

Comments
 (0)