Skip to content

Instantly share code, notes, and snippets.

View scottfister's full-sized avatar

Scotty scottfister

  • Apple
  • San Francisco
View GitHub Profile
{
"cards":[
{
"type":"place",
"title":"McDonald's",
"imageURL":"http://upload.wikimedia.org/wikipedia/commons/thumb/1/17/DowneyMcdonalds.jpg/240px-DowneyMcdonalds.jpg",
"placeCategory":"Fast Food"
},
{
{
"workouts": [
{
"id": 1,
"title": "Chest Pump",
"exercises": [
{
"id": 0,
"title": "Chest Press",
"weight": 80,
var GetURL = function() {};
GetURL.prototype = {
run: function(arguments) {
arguments.completionFunction({"URL": document.URL});
}
};
var ExtensionPreprocessingJS = new GetURL;
let extensionItem = extensionContext?.inputItems.first as! NSExtensionItem
let itemProvider = extensionItem.attachments?.first as! NSItemProvider
let propertyList = String(kUTTypePropertyList)
if itemProvider.hasItemConformingToTypeIdentifier(propertyList) {
itemProvider.loadItem(forTypeIdentifier: propertyList, options: nil, completionHandler: { (item, error) -> Void in
guard let dictionary = item as? NSDictionary else { return }
OperationQueue.main.addOperation {
if let results = dictionary[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary,
let urlString = results["URL"] as? String,
let url = NSURL(string: urlString) {
let imageView = UIImageView(image: UIImage(named: "vurb-icon-rounded"))
imageView.contentMode = .scaleAspectFit
navigationItem.titleView = imageView
navigationController?.navigationBar.topItem?.titleView = imageView
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.backgroundColor = UIColor(red:0.39, green:0.46, blue:0.86, alpha:1.00)
override func configurationItems() -> [Any]! {
if let deck = SLComposeSheetConfigurationItem() {
deck.title = "Selected Deck"
deck.value = "Deck Title"
deck.tapHandler = {
// on tap
}
return [deck]
}
return nil
final class Deck {
var id: String?
var title: String?
}
lazy var tableView: UITableView = {
let tableView = UITableView(frame: self.view.frame)
tableView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
tableView.dataSource = self
tableView.backgroundColor = .clear
tableView.register(UITableViewCell.self, forCellReuseIdentifier: Identifiers.DeckCell)
return tableView
}()
override func viewDidLoad() {
extension ShareSelectViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return userDecks.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: Identifiers.DeckCell, for: indexPath)
cell.textLabel?.text = userDecks[indexPath.row].title
cell.backgroundColor = .clear
return cell
}
private var userDecks = [Deck]()
override func viewDidLoad() {
super.viewDidLoad()
for i in 1...3 {
let deck = Deck()
deck.title = "Deck \(i)"
userDecks.append(deck)
}
// ...