Wikipedia

public final class Wikipedia

The base class from which all the Wikipedia related tasks are initiated. This class is not meant to be instantiated but it serves as a start node to invoke the TaxonomyKit functions in your code.

  • The max width in pixels of the image that the Wikipedia API should return. Defaults to 600.

    Declaration

    Swift

    public var thumbnailWidth: Int
  • Set to true to retrieve Wikipedia extracts as an NSAttributedString. Default is false.

    Declaration

    Swift

    public var usesRichText: Bool
  • Creates a new Wikipedia instance with a given locale. Defaults to system’s.

    Declaration

    Swift

    public init(language: WikipediaLanguage = WikipediaLanguage())

    Parameters

    language

    The WikipediaLanguage object that will be passed to every method called from this instance.

  • Attempts to guess scientific names that could match a specific query using info from the corresponding Wikipedia article.

    Since

    TaxonomyKit 1.5.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func findPossibleScientificNames(matching query: String,
                 callback: @escaping(_ result: Result<[String], TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    query

    The query for which to retrieve Wikipedia metadata.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<[String]> parameter that contains a wrapper with the found names (or [] if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for metadata such as an extract and the Wikipedia page URL for a concrete taxon.

    Since

    TaxonomyKit 1.3.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func retrieveAbstract<T: TaxonRepresenting>(for taxon: T,
                  callback: @escaping (Result<WikipediaResult?, TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    taxon

    The taxon for which to retrieve Wikipedia metadata.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<WikipediaResult?> parameter that contains a wrapper with the requested metadata (or nil if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for metadata such as an extract and the Wikipedia page URL for a concrete Wikipedia Page ID.

    Since

    TaxonomyKit 1.5.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func retrieveAbstract(for identifier: String,
                 callback: @escaping (Result<WikipediaResult?, TaxonomyError>) -> Void) -> URLSessionDataTask

    Parameters

    identifier

    The Wikipedia Page ID for which to retrieve the requested metadata.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<WikipediaResult?> parameter that contains a wrapper with the requested metadata (or nil if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for the Wikipedia page thumbnail for a concrete taxon.

    Since

    TaxonomyKit 1.4.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func retrieveThumbnail<T: TaxonRepresenting>(for taxon: T,
                 callback: @escaping(Result<Data?, TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    taxon

    The taxon for which to retrieve Wikipedia thumbnail.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<Data?> parameter that contains a wrapper with the requested image data (or nil if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for the Wikipedia page thumbnail for a concrete Wikipedia Page ID.

    Since

    TaxonomyKit 1.4.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func retrieveThumbnail(for identifier: String,
                                  callback: @escaping (Result<Data?, TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    identifier

    The Wikipedia Page ID for which to retrieve the requested metadata.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<Data?> parameter that contains a wrapper with the requested image data (or nil if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for the Wikipedia page thumbnail and page extract for a concrete Wikipedia Page ID.

    Since

    TaxonomyKit 1.5.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func retrieveFullRecord(for identifier: String, inlineImage: Bool = false,
                 callback: @escaping (Result<WikipediaResult?, TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    identifier

    The Wikipedia Page ID for which to retrieve the requested metadata.

    inlineImage

    Pass true to download the found thumbnail immediately. Defaults to false, which means onlu the thumbnail URL is returned.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<WikipediaResult?> parameter that contains a wrapper with the requested metadata (or nil if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for the thumbnail and extract of a page whose title matches a given taxon’s scientific name.

    Since

    TaxonomyKit 1.5.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func findPossibleMatch<T: TaxonRepresenting>(for taxon: T, inlineImage: Bool = false,
                  callback: @escaping(Result<WikipediaResult?, TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    taxon

    The taxon whose scientific name will be evaluated to find a matching Wikipedia page.

    inlineImage

    Pass true to download the found thumbnail immediately. Defaults to false, which means onlu the thumbnail URL is returned.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<WikipediaResult?> parameter that contains a wrapper with the requested metadata (or nil if no matching Wikipedia pages are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.

  • Sends an asynchronous request to Wikipedia servers asking for the Wikipedia page thumbnail and page extract for a concrete taxon.

    Since

    TaxonomyKit 1.5.

    Warning

    Please note that the callback may not be called on the main thread.

    Declaration

    Swift

    @discardableResult
    public func retrieveFullRecord<T: TaxonRepresenting>(for taxon: T, inlineImage: Bool = false,
                  callback: @escaping (Result<WikipediaResult?, TaxonomyError>) -> Void) -> URLSessionTask

    Parameters

    taxon

    The taxon for which to retrieve Wikipedia thumbnail.

    inlineImage

    Pass true to download the found thumbnail immediately. Defaults to false, which means onlu the thumbnail URL is returned.

    callback

    A callback closure that will be called when the request completes or if an error occurs. This closure has a TaxonomyResult<WikipediaResult?> parameter that contains a wrapper with the requested metadata (or nil if no results are found) when the request succeeds.

    Return Value

    The URLSessionDataTask object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.