@@ -31,36 +31,36 @@ import XMLKit
31
31
public protocol FeedInitializable : Codable {
32
32
/// Initializes from a URL string pointing to a feed.
33
33
/// - Parameter urlString: The URL string of the feed.
34
- /// - Parameter customDateFormat The optional string that defines weird date formats
34
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
35
35
/// - Throws: An error if the URL string is invalid or loading fails.
36
36
init ( urlString: String , customDateFormatter: DateFormatter ? ) async throws
37
37
38
38
/// Initializes from a URL pointing to a feed.
39
39
/// - Parameter url: The URL of the feed.
40
- /// - Parameter customDateFormat The optional string that defines weird date formats
40
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
41
41
/// - Throws: An error if the URL is invalid or loading fails.
42
42
init ( url: URL , customDateFormatter: DateFormatter ? ) async throws
43
43
44
44
/// Initializes from a file URL.
45
45
/// - Parameter url: The local file URL of the feed.
46
- /// - Parameter customDateFormat The optional string that defines weird date formats
46
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
47
47
/// - Throws: An error if the file cannot be read or parsed.
48
48
init ( fileURL url: URL , customDateFormatter: DateFormatter ? ) throws
49
49
/// Initializes from a remote URL.
50
50
/// - Parameter url: The remote URL of the feed.
51
- /// - Parameter customDateFormat The optional string that defines weird date formats
51
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
52
52
/// - Throws: An error if fetching or parsing fails.
53
53
init ( remoteURL url: URL , customDateFormatter: DateFormatter ? ) async throws
54
54
55
55
/// Initializes from a string.
56
56
/// - Parameter string: The feed content as a string.
57
- /// - Parameter customDateFormat The optional string that defines weird date formats
57
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
58
58
/// - Throws: An error if the string cannot be parsed.
59
59
init ( string: String , customDateFormatter: DateFormatter ? ) throws
60
60
61
61
/// Initializes from data.
62
62
/// - Parameter data: The feed content as raw data.
63
- /// - Parameter customDateFormat The optional string that defines weird date formats
63
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
64
64
/// - Throws: An error if the data cannot be parsed.
65
65
init ( data: Data , customDateFormatter: DateFormatter ? ) throws
66
66
}
@@ -70,7 +70,7 @@ public protocol FeedInitializable: Codable {
70
70
public extension FeedInitializable {
71
71
/// Default implementation for initializing from a URL string.
72
72
/// - Parameter urlString: The URL string of the feed.
73
- /// - Parameter customDateFormat The optional string that defines weird date formats
73
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
74
74
/// - Throws: An error if the feed cannot be loaded or parsed.
75
75
init ( urlString: String , customDateFormatter: DateFormatter ? = nil ) async throws {
76
76
guard let url = URL ( string: urlString) else {
@@ -81,6 +81,7 @@ public extension FeedInitializable {
81
81
82
82
/// Default implementation for initializing from a URL.
83
83
/// - Parameter url: The URL of the feed.
84
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
84
85
/// - Throws: An error if the feed cannot be loaded or parsed.
85
86
init ( url: URL , customDateFormatter: DateFormatter ? = nil ) async throws {
86
87
if url. isFileURL {
@@ -92,7 +93,7 @@ public extension FeedInitializable {
92
93
93
94
/// Initializes from a file URL.
94
95
/// - Parameter url: The local file URL of the feed.
95
- /// - Parameter url : The URL of the feed.
96
+ /// - Parameter customDateFormatter : The optional `DateFormatter` that can be used to handle weird formats
96
97
/// - Throws: An error if the file cannot be read or parsed.
97
98
init ( fileURL url: URL , customDateFormatter: DateFormatter ? = nil ) throws {
98
99
let data = try Data ( contentsOf: url)
@@ -101,7 +102,7 @@ public extension FeedInitializable {
101
102
102
103
/// Initializes from a remote URL.
103
104
/// - Parameter url: The remote URL of the feed.
104
- /// - Parameter url : The URL of the feed.
105
+ /// - Parameter customDateFormatter : The optional `DateFormatter` that can be used to handle weird formats
105
106
/// - Throws: An error if fetching or parsing fails.
106
107
init ( remoteURL url: URL , customDateFormatter: DateFormatter ? = nil ) async throws {
107
108
let session : URLSession = . shared
@@ -121,7 +122,7 @@ public extension FeedInitializable {
121
122
122
123
/// Default implementation for initializing from a string.
123
124
/// - Parameter string: The feed content as a string.
124
- /// - Parameter url : The URL of the feed.
125
+ /// - Parameter customDateFormatter : The optional `DateFormatter` that can be used to handle weird formats
125
126
/// - Throws: An error if the string cannot be converted to data or parsed.
126
127
init ( string: String , customDateFormatter: DateFormatter ? = nil ) throws {
127
128
guard let data = string. data ( using: . utf8) else {
@@ -132,7 +133,7 @@ public extension FeedInitializable {
132
133
133
134
/// Default implementation for initializing from data.
134
135
/// - Parameter data: The feed content as raw data.
135
- /// - Parameter url : The URL of the feed.
136
+ /// - Parameter customDateFormatter : The optional `DateFormatter` that can be used to handle weird formats
136
137
/// - Throws: An error if parsing or decoding fails.
137
138
init ( data: Data , customDateFormatter: DateFormatter ? = nil ) throws {
138
139
self = try Self . decode ( data: data, customDateFormatter: customDateFormatter)
@@ -144,6 +145,7 @@ public extension FeedInitializable {
144
145
extension FeedInitializable {
145
146
/// Helper method for decoding data into a model.
146
147
/// - Parameter data: The raw feed data.
148
+ /// - Parameter customDateFormatter: The optional `DateFormatter` that can be used to handle weird formats
147
149
/// - Returns: A parsed feed model conforming to `FeedInitializable`.
148
150
private static func decode( data: Data , customDateFormatter: DateFormatter ? = nil ) throws -> Self {
149
151
let decoder : XMLDecoder = . init( )
0 commit comments