Belajar dari Apple adalah cara terbaik.
Misalnya, notifikasi keyboard Apple:
extension UIResponder {
public class let keyboardWillShowNotification: NSNotification.Name
public class let keyboardDidShowNotification: NSNotification.Name
public class let keyboardWillHideNotification: NSNotification.Name
public class let keyboardDidHideNotification: NSNotification.Name
}
Sekarang saya belajar dari Apple:
extension User {
/// user did login notification
static let userDidLogInNotification = Notification.Name(rawValue: "User.userDidLogInNotification")
}
Terlebih lagi NSAttributedString.Key.foregroundColor
,:
extension NSAttributedString {
public struct Key : Hashable, Equatable, RawRepresentable {
public init(_ rawValue: String)
public init(rawValue: String)
}
}
extension NSAttributedString.Key {
/************************ Attributes ************************/
@available(iOS 6.0, *)
public static let foregroundColor: NSAttributedString.Key // UIColor, default blackColor
}
Sekarang saya belajar dari Apple:
extension UIFont {
struct Name {
}
}
extension UIFont.Name {
static let SFProText_Heavy = "SFProText-Heavy"
static let SFProText_LightItalic = "SFProText-LightItalic"
static let SFProText_HeavyItalic = "SFProText-HeavyItalic"
}
pemakaian:
let font = UIFont.init(name: UIFont.Name.SFProText_Heavy, size: 20)
Belajar dari Apple adalah cara yang dapat dilakukan semua orang dan dapat mempromosikan kualitas kode Anda dengan mudah.