Skip to content

Instantly share code, notes, and snippets.

@hartbit
Created May 28, 2015 09:04
Show Gist options
  • Save hartbit/9b47de73ac5fc74f0291 to your computer and use it in GitHub Desktop.
Save hartbit/9b47de73ac5fc74f0291 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
protocol PlaceholderText : class, UITextInputTraits {
var placeholder: String? { get set }
}
extension UITextField: PlaceholderText { }
extension UITextView: PlaceholderText {
var placeholder: String? {
get { return "" }
set { }
}
}
var textFieldOrView: PlaceholderText = UITextView()
textFieldOrView.placeholder = "Placeholder"
textFieldOrView.autocapitalizationType = .Words // Compilation Error: Cannot assign to the result of this expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment