//
//  ArticlePasteboardWriter.swift
//  Evergreen
//
//  Created by Brent Simmons on 11/6/17.
//  Copyright © 2017 Ranchero Software. All rights reserved.
//

import Cocoa
import Data

@objc final class ArticlePasteboardWriter: NSObject, NSPasteboardWriting {

	private let article: Article

	init(article: Article) {

		self.article = article
	}

	// MARK: - NSPasteboardWriting

	func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {

		// TODO: add more types

		var types = [NSPasteboard.PasteboardType]()

		if let _ = article.title {
			types += [.string]
		}

		return types // TODO: add types
	}

	func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? {

		// TODO: write data for all types declared in writableTypes.

		let plist: Any?

		switch type {
		case .string:
			plist = article.title ?? ""
		default:
			plist = nil
		}

		return plist
	}
}

//
//  ArticlePasteboardWriter.swift
//  Evergreen
//
//  Created by Brent Simmons on 11/6/17.
//  Copyright © 2017 Ranchero Software. All rights reserved.
//

import Cocoa
import Data

@objc final class ArticlePasteboardWriter: NSObject, NSPasteboardWriting {

	private let article: Article

	init(article: Article) {

		self.article = article
	}

	// MARK: - NSPasteboardWriting

	func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {

		return [NSPasteboard.PasteboardType]() // TODO: add types
	}

	func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? {

		return nil // TODO: write data
	}
}

--- 
+++ 
@@ -22,11 +22,30 @@
 
 	func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
 
-		return [NSPasteboard.PasteboardType]() // TODO: add types
+		// TODO: add more types
+
+		var types = [NSPasteboard.PasteboardType]()
+
+		if let _ = article.title {
+			types += [.string]
+		}
+
+		return types // TODO: add types
 	}
 
 	func pasteboardPropertyList(forType type: NSPasteboard.PasteboardType) -> Any? {
 
-		return nil // TODO: write data
+		// TODO: write data for all types declared in writableTypes.
+
+		let plist: Any?
+
+		switch type {
+		case .string:
+			plist = article.title ?? ""
+		default:
+			plist = nil
+		}
+
+		return plist
 	}
 }
Write the string plist for the article.
