From 5be2dd20395202b11a63c81e2c1b3230883222d8 Mon Sep 17 00:00:00 2001 From: Philip Bui Date: Mon, 18 Feb 2019 23:00:00 +1100 Subject: [PATCH] Updated README usage sample to cleaner Swift conventions Updated README Usage sample to use implicit returns, and lazy init. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d1e89cf..9ed75fd 100644 --- a/README.md +++ b/README.md @@ -66,13 +66,13 @@ AsYouTypeFormatter.tagAttributes = [NSAttributedString.Key.font: UIFont.boldSyst AsYouTypeFormatter.mentionAttributes = [NSAttributedString.Key.font: UIFont.italicSystemFont(ofSize: 16)] // ViewController.swift - Customize own character prefixes and formats. -private var typeFormatter: AsYouTypeFormatter { - let typeFormatter = AsYouTypeFormatter(delegate: self, attributes: [ +private lazy var typeFormatter: AsYouTypeFormatter = { + // Implicit return. + AsYouTypeFormatter(delegate: self, attributes: [ "#": [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16)], nil: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)] ]) - return typeFormatter -} +}() ``` ## Design Decisions