Add a dummy extension
This commit is contained in:
parent
208e7f9f55
commit
8f91c4c516
32 changed files with 537 additions and 1 deletions
47
passextension/ActionViewController.swift
Normal file
47
passextension/ActionViewController.swift
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// ActionViewController.swift
|
||||
// passforiosextension
|
||||
//
|
||||
// Created by Yishi Lin on 9/6/17.
|
||||
// Copyright © 2017 Yishi Lin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MobileCoreServices
|
||||
|
||||
class ActionViewController: UIViewController {
|
||||
|
||||
@IBOutlet weak var textView: UITextView!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let item = extensionContext?.inputItems.first as! NSExtensionItem
|
||||
let provider = item.attachments?.first as! NSItemProvider
|
||||
let propertyList = String(kUTTypePropertyList)
|
||||
if provider.hasItemConformingToTypeIdentifier(propertyList) {
|
||||
provider.loadItem(forTypeIdentifier: propertyList, options: nil, completionHandler: { (item, error) -> Void in
|
||||
let dictionary = item as! NSDictionary
|
||||
let results = dictionary[NSExtensionJavaScriptPreprocessingResultsKey] as! NSDictionary
|
||||
let url = results["url"] as? String
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.textView.text = url
|
||||
}
|
||||
})
|
||||
} else {
|
||||
print("error")
|
||||
}
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@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)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue