RSDResourceTransformer
public protocol RSDResourceTransformer: RSDDecodableBundleInfo
RSDResourceTransformer is a protocol for getting either embedded resources or online resources.
-
Either a fully qualified URL string or else a relative reference to either an embedded resource or a relative URL defined globally by overriding the
RSDResourceConfigclass methods.Declaration
Swift
var resourceName: String -
The classType for converting the resource to an object.
Declaration
Swift
var classType: String?
-
estimatedFetchTimeExtension methodThe estimated time required to fetch the resource.
Declaration
Swift
public var estimatedFetchTime: TimeInterval -
isOnlineResourceURL()Extension methodWhether or not the resource is an online URL or from an embedded resource bundle.
Declaration
Swift
public func isOnlineResourceURL() -> BoolReturn Value
trueif the resource is an online URL orfalseif it is an embedded resource. -
resourceURL(ofType:bundle:)Extension methodGet the URL for a given resource. This can return either a URL to an online resource or a URL for an embedded resource.
Throws
RSDResourceTransformerErrorif the file cannot be found.Declaration
Swift
public func resourceURL(ofType defaultExtension: String? = nil, bundle: Bundle? = nil) throws -> (url: URL, resourceType: RSDResourceType)Parameters
defaultExtensionThe default extension for the URL. If
nilthen theresourceNamewill be inspected for a file extension. If that isnilthenjson
will be assumed.bundleThe bundle to use for fetching the resource. If
nilthen theRSDResourceConfigwill be used.Return Value
- url: The returned URL for this resource.
- resourceType: The resource type.
-
resourceData(ofType:bundle:)Extension methodGet the
Datafor a given resource. This is used to get data from an embedded resource.Throws
RSDResourceTransformerErrorif the file cannot be found.Declaration
Swift
public func resourceData(ofType defaultExtension: String? = nil, bundle: Bundle? = nil) throws -> (data: Data, resourceType: RSDResourceType)Parameters
defaultExtensionThe default extension for the URL. If
nilthen theresourceNamewill be inspected for a file extension. If that isnilthenjson
will be assumed.bundleThe bundle to use for fetching the resource. If
nilthen theRSDResourceConfigwill be used.Return Value
- data: The returned Data for this resource.
- resourceType: The resource type.
View on GitHub
RSDResourceTransformer Protocol Reference