Hi everyone,
Recently I am developing Drag&Drop function on iPad and met a problem: I
can not get Pages/Numbers/Keynote files from performDrop
in UIDropInteractionDelegate. Here is my solution:
1. Create my own file item provider, follow the protocol
NSItemProviderReading.
2. *override method readableTypeIdentifiersForItemProvider, register UTI of
iWorks files which are com.apple.iwork.pages.sffpages,
com.apple.iwork.numbers.sffnumbers and com.apple.keynote.key.* I got those
UTI from [[NSWorkspace sharedWorkspace] typeOfFile:filePath error:nil]
3. override + (instancetype)objectWithItemProviderData:(NSData *)data
typeIdentifier:(NSString *)typeIdentifier error:(NSError * _Nullable
__autoreleasing *)outError
4. implement canHandleSession of UIDropInteractionDelegate and return [session
canLoadObjectsOfClass:[DTFileItemProvider class]]
I do the same thing on office files, and it work very well, I can get
file's data in performDrop. But iWorks file are not.
This isn't an appropriate question for the swift-evolution list. You might like to ask it on one of the Apple developer forums at https://forums.developer.apple.com
Alex
···
On 2 Oct 2017, at 08:23, Yun Zeng via swift-evolution <swift-evolution@swift.org> wrote:
Hi everyone,
Recently I am developing Drag&Drop function on iPad and met a problem: I can not get Pages/Numbers/Keynote files from performDrop in UIDropInteractionDelegate. Here is my solution:
1. Create my own file item provider, follow the protocol NSItemProviderReading.
2. override method readableTypeIdentifiersForItemProvider, register UTI of iWorks files which are com.apple.iwork.pages.sffpages, com.apple.iwork.numbers.sffnumbers and com.apple.keynote.key. I got those UTI from [[NSWorkspace sharedWorkspace] typeOfFile:filePath error:nil]
3. override + (instancetype)objectWithItemProviderData:(NSData *)data typeIdentifier:(NSString *)typeIdentifier error:(NSError * _Nullable __autoreleasing *)outError
4. implement canHandleSession of UIDropInteractionDelegate and return [session canLoadObjectsOfClass:[DTFileItemProvider class]]
I do the same thing on office files, and it work very well, I can get file's data in performDrop. But iWorks file are not.
So did I set the wrong UTI or something?
--
Zeng Yun
iOS Engineer
Email/QQ: zengyun.programmer@gmail.com <mailto:zengyun.programmer@gmail.com>_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution
Alex Blewitt <alblue@apple.com>于2017年10月2日周一 下午6:24写道:
This isn't an appropriate question for the swift-evolution list. You might
like to ask it on one of the Apple developer forums at https://forums.developer.apple.com
Alex
Hi everyone,
Recently I am developing Drag&Drop function on iPad and met a problem: I
can not get Pages/Numbers/Keynote files from performDrop
in UIDropInteractionDelegate. Here is my solution:
1. Create my own file item provider, follow the protocol
NSItemProviderReading.
2. *override method readableTypeIdentifiersForItemProvider, register UTI
of iWorks files which are com.apple.iwork.pages.sffpages,
com.apple.iwork.numbers.sffnumbers and com.apple.keynote.key.* I got
those UTI from [[NSWorkspace sharedWorkspace] typeOfFile:filePath error:
nil]
3. override + (instancetype)objectWithItemProviderData:(NSData *)data
typeIdentifier:(NSString *)typeIdentifier error:(NSError * _Nullable
__autoreleasing *)outError
4. implement canHandleSession of UIDropInteractionDelegate and return [session
canLoadObjectsOfClass:[DTFileItemProvider class]]
I do the same thing on office files, and it work very well, I can get
file's data in performDrop. But iWorks file are not.
So did I set the wrong UTI or something?
--
Zeng Yun
iOS Engineer
Email/QQ: zengyun.programmer@gmail.com