URLSession
public extension URLSession
-
Returns a task for fetching and parsing articles specified by provided request.
The completion handler takes a single
Result
argument, which is either a succesfuly parsedArxivResponse
or an error, if one occurs. The error is eitherArxivURLError
,ArxivServerError
,ArxivParserError
orArxivAPIError
.Note
Completion handler is called on session’sdelegateQueue
.Declaration
Swift
func fetchTask(with request: ArxivRequest, completion: @escaping ArxivFetchTaskCompetionHandler) -> URLSessionDataTask
Parameters
request
An
ArxivRequest
value that specifies the articles to be fetched by the task.completion
A function to be called after the task finishes.
-
arxivResponse(for:
Asynchronousdelegate: ) Downloads and parses articles specified by provided request and delivers the result asynchronously.
Throws
An error which is either
ArxivURLError
,ArxivServerError
,ArxivParserError
orArxivAPIError
.Declaration
Swift
@available(macOS 12.0.0, iOS 15.0.0, *) func arxivResponse(for request: ArxivRequest, delegate: URLSessionTaskDelegate? = nil) async throws -> ArxivResponse
Parameters
request
An
ArxivRequest
value that specifies the articles to be fetched asynchronously.delegate
A delegate that receives life cycle and authentication challenge callbacks as the transfer progresses.
-
Returns a task for fetching and parsing articles specified by provided request.
When the task completes, a result is assigned to property indicated by
keyPath
on the provided object.The result is either a succesfuly parsed
ArxivResponse
or an error, if one occurs. The error is eitherArxivURLError
,ArxivServerError
,ArxivParserError
orArxivAPIError
.Note
The assignment happens on session’sdelegateQueue
.Declaration
Swift
func fetchTask<Root>( with request: ArxivRequest, assignResultTo keyPath: ArxivFetchResultKeypath<Root>, on object: Root ) -> URLSessionDataTask
Parameters
request
An
ArxivRequest
value that specifies the articles to be fetched by the task.keyPath
A key path that indicates the property to assign.
object
The object that contains the property.