Skip to content

Commit

Permalink
Run actions on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmo committed Nov 29, 2016
1 parent c3480e6 commit d4c43f7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions TinyConsole/TinyConsole.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ open class TinyConsole {
}

public func print(text: String, global: Bool = true) {
if let textView = self.textView {
textView.text.append(self.currentTimeStamp() + " " + text + "\n")
self.scrollToBottom()
}
if global {
Swift.print(text)
DispatchQueue.main.async {
if let textView = self.textView {
textView.text.append(self.currentTimeStamp() + " " + text + "\n")
self.scrollToBottom()
}
if global {
Swift.print(text)
}
}
}

public func clear() {
self.textView?.text = ""
self.scrollToBottom()
DispatchQueue.main.async {
self.textView?.text = ""
self.scrollToBottom()
}
}

public func addMarker() {
Expand Down

0 comments on commit d4c43f7

Please sign in to comment.