<div dir="ltr">Hi everyone,<div>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:</div><div><br></div><div>1. Create my own file item provider, follow the protocol NSItemProviderReading. </div><div>2. <b>override method readableTypeIdentifiersForItemProvider, register UTI of iWorks files which are <font color="#ff0000">com.apple.iwork.pages.sffpages, com.apple.iwork.numbers.sffnumbers and com.apple.keynote.key.</font></b> I got those UTI from <span class="inbox-inbox-s1">[[</span>NSWorkspace<span class="inbox-inbox-s1"> </span>sharedWorkspace<span class="inbox-inbox-s1">] </span>typeOfFile<span class="inbox-inbox-s1">:filePath </span>error<span class="inbox-inbox-s1">:</span><span class="inbox-inbox-s2">nil</span><span class="inbox-inbox-s1">]</span></div><div><span class="inbox-inbox-s1">3. override </span>+ (<span class="inbox-inbox-s1">instancetype</span>)objectWithItemProviderData:(<span class="inbox-inbox-s2">NSData</span> *)data typeIdentifier:(<span class="inbox-inbox-s2">NSString</span> *)typeIdentifier error:(<span class="inbox-inbox-s2">NSError</span> * <span class="inbox-inbox-s1">_Nullable</span> <span class="inbox-inbox-s1">__autoreleasing</span> *)outError</div><div>4. implement canHandleSession of UIDropInteractionDelegate and return <span class="inbox-inbox-s1">[session </span>canLoadObjectsOfClass<span class="inbox-inbox-s1">:[</span><span class="inbox-inbox-s2">DTFileItemProvider</span><span class="inbox-inbox-s1"> </span>class<span class="inbox-inbox-s1">]]</span></div><div><br></div><div>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.</div><div><br></div><div>So did I set the wrong UTI or something?</div>
</div><div dir="ltr">-- <br></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;line-height:19.5px">Zeng Yun</div><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;line-height:19.5px">iOS Engineer</div><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;line-height:19.5px">Email/QQ:<span class="inbox-inbox-Apple-converted-space"> </span><a href="mailto:zengyun.programmer@gmail.com" target="_blank">zengyun.programmer@gmail.com</a></div></div></div>