-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mimeTyp that can't be recognise #13
Comments
@turk-jk Hi. I could reproduce the behavior. // Create UIImage
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 10, height: 10))
let image = renderer.image { _ in }
// Set image to pasteboard
let pasteboard = UIPasteboard.general
pasteboard.image = image
// Reproduced here
for item in pasteboard.items {
let UTIs = item.keys.map(UTI.init)
print(UTIs) // [public.png, public.jpeg, com.apple.uikit.image]
} I think that You should filter that. let imageType = UTI(kUTTypeImage as String)
for item in pasteboard.items {
// Filter by conformance
let UTIs = item.keys.map(UTI.init).filter { imageType ~= $0 }
print(UTIs) // [public.png, public.jpeg]
} |
Great tip.
I will try it
Thanks.
…On Tue, 12 Mar 2019 at 11:55 am Hiroki Kato ***@***.***> wrote:
@turk-jk <https://github.com/turk-jk> Hi.
I could reproduce the behavior.
// Create UIImagelet renderer = UIGraphicsImageRenderer(size: CGSize(width: 10, height: 10))let image = renderer.image { _ in }
// Set image to pasteboardlet pasteboard = UIPasteboard.general
pasteboard.image = image
// Reproduced herefor item in pasteboard.items {
let UTIs = item.keys.map(UTI.init)
print(UTIs) // [public.png, public.jpeg, com.apple.uikit.image]}
I think that com.apple.uikit.image is the UIKit internal UTI.
You should filter that.
let imageType = UTI(kUTTypeImage as String)for item in pasteboard.items {
// Filter by conformance let UTIs = item.keys.map(UTI.init).filter { imageType ~= $0 }
print(UTIs) // [public.png, public.jpeg]}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKjEu8qLtblyFShabefUGapXdD3G6Fw2ks5vVyU8gaJpZM4boLp6>
.
|
I have just tested your code which works fine, but doesn't serve my app purpose well as it receive many different type of data not only
prints
Now I understand that I am relaying on the condition thanks |
Hi there,
I'm using Xcode 10.1
swift 4.2 tested on simulator, iphone and playground
when I init an UTI
let uti = UTI("com.apple.uikit.image") print(uti.declaration)
it prints
// [:]
- Background of the problem
the reason I need this because when I copy an image from WhatsApp, WhatsApp will add one item that has three items in the
`let paste = UIPasteboard.general.item // type of [[String : Any]]
print (paste)
// [["public.png": <UIImage: 0x2821b5730>, {1024, 1017}, "public.jpeg": <UIImage: 0x2821e5c70>, {1024, 1017}, "com.apple.uikit.image": <OS_dispatch_data: data[0x2810a6c40] = { leaf, size = 1015803, buf = 0x11c6fc000 }>]]`
you can see WhatsApp add
[["public.png" "public.jpeg", "com.apple.uikit.image"]]
I always take only the first item of those three and their order changes sometimes, the problem occur when
"com.apple.uikit.image"
is the first itemthanks
The text was updated successfully, but these errors were encountered: