diff --git a/HakawaiDemoSwift/.DS_Store b/HakawaiDemoSwift/.DS_Store new file mode 100644 index 0000000..a7c21bc Binary files /dev/null and b/HakawaiDemoSwift/.DS_Store differ diff --git a/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/project.pbxproj b/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/project.pbxproj index 445d323..a97ec09 100755 --- a/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/project.pbxproj +++ b/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/project.pbxproj @@ -398,7 +398,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = HLS658NRU7; - INFOPLIST_FILE = HakawaiDemoSwift/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/HakawaiDemoSwift/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.linkedin.HakawaiDemoSwift; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -414,7 +414,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = HLS658NRU7; - INFOPLIST_FILE = HakawaiDemoSwift/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/HakawaiDemoSwift/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.linkedin.HakawaiDemoSwift; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/xcuserdata/sergstavitskii.xcuserdatad/xcschemes/xcschememanagement.plist b/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/xcuserdata/sergstavitskii.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100755 index 30c038d..0000000 --- a/HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/xcuserdata/sergstavitskii.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - SchemeUserState - - HakawaiDemoSwift.xcscheme - - orderHint - 2 - - - - diff --git a/HakawaiDemoSwift/HakawaiDemoSwift.xcworkspace/xcuserdata/sergstavitskii.xcuserdatad/UserInterfaceState.xcuserstate b/HakawaiDemoSwift/HakawaiDemoSwift.xcworkspace/xcuserdata/sergstavitskii.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..19145ea Binary files /dev/null and b/HakawaiDemoSwift/HakawaiDemoSwift.xcworkspace/xcuserdata/sergstavitskii.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsDemoViewController.swift b/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsDemoViewController.swift index a7e72bf..ca7e377 100755 --- a/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsDemoViewController.swift +++ b/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsDemoViewController.swift @@ -19,15 +19,12 @@ class MentionsDemoViewController: UIViewController { @IBOutlet weak var textView: HKWTextView! @IBOutlet weak var mentionsListButton: UIButton! - // - private var plugin: HKWMentionsPlugin! + private var plugin: HKWMentionsPlugin? override func viewDidLoad() { super.viewDidLoad() setupUI() } - - } // MARK: - @@ -54,10 +51,9 @@ extension MentionsDemoViewController { // Add edge insets so chooser view doesn't overlap the text view's cosmetic grey border mentionsPlugin?.chooserViewEdgeInsets = UIEdgeInsetsMake(2, 0.5, 0.5, 0.5) plugin = mentionsPlugin - plugin.chooserViewBackgroundColor = .lightGray + plugin?.chooserViewBackgroundColor = .lightGray // The mentions plug-in requires a delegate, which provides it with mentions entities in response to a query string mentionsPlugin?.delegate = MentionsManager.shared -// mentionsPlugin?.stateChangeDelegate = textView.controlFlowPlugin = mentionsPlugin } } @@ -66,7 +62,7 @@ extension MentionsDemoViewController { extension MentionsDemoViewController { @IBAction func listMentionsButtonTapped(_ sender: UIButton) { - print("There are mention(s): \(plugin.mentions().count) @% \(plugin.mentions())") + print("There are mention(s): \(String(describing: plugin?.mentions().count)) @% \(String(describing: plugin?.mentions()))") } @IBAction func doneEditingButtonTapped(_ sender: UIButton) { diff --git a/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsEntity.swift b/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsEntity.swift index b30b425..8671e20 100755 --- a/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsEntity.swift +++ b/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsEntity.swift @@ -15,7 +15,7 @@ import Hakawai class MentionsEntity: NSObject { - private var name: String! + private var name: String? private var id: String! init(name: String, id: String) { diff --git a/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsManager.swift b/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsManager.swift index 232a941..d3a017e 100755 --- a/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsManager.swift +++ b/HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsManager.swift @@ -17,6 +17,8 @@ class MentionsManager: NSObject { static let shared = MentionsManager() + private let mentionsCellId = "mentionsCell" + private let mentionsCellHeight: CGFloat = 44.0 private var fakeData = [MentionsEntity]() private func setupFakeData() { @@ -42,8 +44,9 @@ extension MentionsManager: HKWMentionsDelegate { // perform whatever work is necessary to get the entities for that search string (network call, database query, etc), // and then to call the completion block with an array of entity objects corresponding to the search string. See the // documentation for the method for more details. - func asyncRetrieveEntities(forKeyString keyString: String!, searchType type: HKWMentionsSearchType, controlCharacter character: unichar, completion completionBlock: (([Any]?, Bool, Bool) -> Void)!) { - if completionBlock == nil { + func asyncRetrieveEntities(forKeyString keyString: String!, searchType type: HKWMentionsSearchType, controlCharacter character: unichar, + completion completionBlock: (([Any]?, Bool, Bool) -> Void)!) { + guard completionBlock != nil else { return } setupFakeData() @@ -66,9 +69,9 @@ extension MentionsManager: HKWMentionsDelegate { // In this method, the plug-in gives us a mentions entity (one we previously returned in response to a query), and asks // us to provide a table view cell corresponding to that entity to be presented to the user. func cell(forMentionsEntity entity: HKWMentionsEntityProtocol!, withMatch matchString: String!, tableView: UITableView!) -> UITableViewCell! { - var cell = tableView.dequeueReusableCell(withIdentifier: "mentionsCell") + var cell = tableView.dequeueReusableCell(withIdentifier: mentionsCellId) if cell == nil { - cell = UITableViewCell(style: .subtitle, reuseIdentifier: "mentionsCell") + cell = UITableViewCell(style: .subtitle, reuseIdentifier: mentionsCellId) cell?.backgroundColor = .lightGray } cell?.textLabel?.text = entity.entityName() @@ -77,7 +80,7 @@ extension MentionsManager: HKWMentionsDelegate { } func heightForCell(forMentionsEntity entity: HKWMentionsEntityProtocol!, tableView: UITableView!) -> CGFloat { - return 44 + return mentionsCellHeight } diff --git a/HakawaiDemoSwift/Podfile.lock b/HakawaiDemoSwift/Podfile.lock index 89ea4a3..6654fef 100755 --- a/HakawaiDemoSwift/Podfile.lock +++ b/HakawaiDemoSwift/Podfile.lock @@ -1,16 +1,16 @@ PODS: - - Hakawai (5.1.1): - - Hakawai/Core (= 5.1.1) - - Hakawai/Mentions (= 5.1.1) - - Hakawai/Core (5.1.1) - - Hakawai/Mentions (5.1.1): + - Hakawai (5.1.4): + - Hakawai/Core (= 5.1.4) + - Hakawai/Mentions (= 5.1.4) + - Hakawai/Core (5.1.4) + - Hakawai/Mentions (5.1.4): - Hakawai/Core DEPENDENCIES: - Hakawai SPEC CHECKSUMS: - Hakawai: 98dfeb08fce7c1ae9310089020c358a98acf29b5 + Hakawai: b525498fdef6485445127d615a65cbee5f0cfea2 PODFILE CHECKSUM: 8afb544880f2856932d1fd9950c29e8e1627c5ba