Skip to content

Commit

Permalink
Pass kCGImageSourceTypeIdentifierHint as a UTI
Browse files Browse the repository at this point in the history
We were passing this as a MIME type, but the key actually expects a UTI.

Fixes #62.
  • Loading branch information
lilyball committed Apr 24, 2019
1 parent 50ebcbe commit f375237
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,15 @@ work by you shall be dual licensed as above, without any additional terms or con

## Version History

#### Development

* Fix a bug when parsing images where we passed the wrong value for the type identifier hint, resulting in a warning being logged to the console ([#62][]).

[#62]: https://github.com/postmates/PMHTTP/issues/62 "Unknown Hint Identifier for Image MIME Types · Issue #62 · postmates/PMHTTP"

#### v4.3.3 (2019-04-07)

* Updated `PMHTTPErrorIsFailedResponse` to handle `PMHTTPErrorUnexpectedNoContent` and `PMHTTPErrorUnexpectedRedirect` in addition to `PMHTTPErrorFailedResponse` and `PMHTTPErrorUnauthorized`.
* Update `PMHTTPErrorIsFailedResponse` to handle `PMHTTPErrorUnexpectedNoContent` and `PMHTTPErrorUnexpectedRedirect` in addition to `PMHTTPErrorFailedResponse` and `PMHTTPErrorUnauthorized`.
* Fix warnings introduced by Xcode 10.2.

#### v4.3.2 (2018-11-14)
Expand Down
6 changes: 4 additions & 2 deletions Sources/PlatformSpecific.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,10 @@ import Foundation
// Use CGImageSource so we can provide the MIME type hint.
// NB: CGImageSource will cache the decoded image data by default on 64-bit platforms.
let options: NSDictionary?
if let mimeType = mimeType {
options = [kCGImageSourceTypeIdentifierHint: mimeType as CFString]
if let mimeType = mimeType,
let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType as CFString, kUTTypeImage)?.takeRetainedValue()
{
options = [kCGImageSourceTypeIdentifierHint: uti]
} else {
options = nil
}
Expand Down

0 comments on commit f375237

Please sign in to comment.