You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
662 B
27 lines
662 B
// |
|
// Data+FileResource.swift |
|
// R.swift.Library |
|
// |
|
// Created by Tom Lokhorst on 2016-03-11. |
|
// From: https://github.com/mac-cain13/R.swift.Library |
|
// License: MIT License |
|
// |
|
|
|
import Foundation |
|
|
|
public struct NoUrlForResourceError: Error {} |
|
|
|
public extension Data { |
|
|
|
/** |
|
Creates and returns NSData with the contents of the specified file resource (R.file.*). |
|
|
|
- parameter resource: The file resource (R.file.*) |
|
|
|
- returns: A NSData object with the contents of the specified file. |
|
*/ |
|
init(resource: FileResourceType) throws { |
|
guard let url = resource.url() else { throw NoUrlForResourceError() } |
|
try self.init(contentsOf: url) |
|
} |
|
}
|
|
|