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
trueto retrieve Wikipedia extracts as anNSAttributedString. Default isfalse.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
languageThe
WikipediaLanguageobject 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) -> URLSessionTaskParameters
queryThe query for which to retrieve Wikipedia metadata.
callbackA 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
URLSessionDataTaskobject 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) -> URLSessionTaskParameters
taxonThe taxon for which to retrieve Wikipedia metadata.
callbackA 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 (ornilif no results are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject 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) -> URLSessionDataTaskParameters
identifierThe Wikipedia Page ID for which to retrieve the requested metadata.
callbackA 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 (ornilif no results are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject 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) -> URLSessionTaskParameters
taxonThe taxon for which to retrieve Wikipedia thumbnail.
callbackA 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 (ornilif no results are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject 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) -> URLSessionTaskParameters
identifierThe Wikipedia Page ID for which to retrieve the requested metadata.
callbackA 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 (ornilif no results are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject 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) -> URLSessionTaskParameters
identifierThe Wikipedia Page ID for which to retrieve the requested metadata.
inlineImagePass
trueto download the found thumbnail immediately. Defaults tofalse, which means onlu the thumbnail URL is returned.callbackA 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 (ornilif no results are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject 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) -> URLSessionTaskParameters
taxonThe taxon whose scientific name will be evaluated to find a matching Wikipedia page.
inlineImagePass
trueto download the found thumbnail immediately. Defaults tofalse, which means onlu the thumbnail URL is returned.callbackA 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 (ornilif no matching Wikipedia pages are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject 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) -> URLSessionTaskParameters
taxonThe taxon for which to retrieve Wikipedia thumbnail.
inlineImagePass
trueto download the found thumbnail immediately. Defaults tofalse, which means onlu the thumbnail URL is returned.callbackA 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 (ornilif no results are found) when the request succeeds.Return Value
The
URLSessionDataTaskobject that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.
View on GitHub
Install in Dash
Wikipedia Class Reference