2021-11-05 19:12:04 +00:00
|
|
|
import UIKit
|
|
|
|
import MobileCoreServices
|
|
|
|
import UniformTypeIdentifiers
|
|
|
|
|
|
|
|
class ActionViewController: UIViewController {
|
|
|
|
|
|
|
|
@IBOutlet weak var imageView: UIImageView!
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
2021-11-05 19:40:36 +00:00
|
|
|
|
2021-11-05 19:12:04 +00:00
|
|
|
// Get the item[s] we're handling from the extension context.
|
2021-11-05 19:40:36 +00:00
|
|
|
if let inputItem = extensionContext?.inputItems.first as? NSExtensionItem {
|
|
|
|
if let itemProvider = inputItem.attachments?.first {
|
|
|
|
itemProvider.loadItem(forTypeIdentifier: kUTTypePropertyList as String) { [weak self] dict, error in
|
|
|
|
guard let itemDictionary = dict as? NSDictionary else { return }
|
|
|
|
guard let javaScriptValues = itemDictionary[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary else { return }
|
|
|
|
print(javaScriptValues)
|
2021-11-05 19:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func done() {
|
|
|
|
// Return any edited content to the host app.
|
|
|
|
// This template doesn't do anything, so we just echo the passed in items.
|
|
|
|
self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|