Compare commits

..

3 Commits

Author SHA1 Message Date
Duraid Abdul da9d78f559 Merge branch 'main' of https://github.com/duraidabdul/LocalConsole 2022-01-21 12:47:53 -08:00
Duraid Abdul 50e4ce4e03 Update LCManager.swift 2022-01-21 12:47:50 -08:00
Duraid Abdul ae73be37b4 Update README.md 2022-01-17 12:08:39 -08:00
2 changed files with 23 additions and 5 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ let consoleManager = LCManager.shared
```
## **Usage**
Once prepared, the localConsole can be used throughout your project.
Once prepared, the consoleManager can be used throughout your project.
```swift
// Activate the console view.
+22 -4
View File
@@ -534,10 +534,20 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
/// Print items to the console view.
public func print(_ items: Any) {
if currentText == "" {
currentText = "\(items)"
let _currentText: String = {
if currentText == "" {
return "\(items)"
} else {
return currentText + "\n\(items)"
}
}()
// Cut down string if it exceeds 300,000 characters to keep text view running smoothly.
if _currentText.count > 300000 {
let shortenedString = String(_currentText.suffix(300000))
currentText = shortenedString.stringAfterFirstOccurenceOf(delimiter: "\n") ?? shortenedString
} else {
currentText = currentText + "\n\(items)"
currentText = _currentText
}
}
@@ -1134,7 +1144,7 @@ class InvertedTextView: UITextView {
var pendingOffsetChange = false
// Thanks to WWDC21 Lab!
// Thanks to WWDC21 UIKit Lab!
override func layoutSubviews() {
super.layoutSubviews()
@@ -1166,6 +1176,14 @@ extension UIDevice {
}
}
extension String {
func stringAfterFirstOccurenceOf(delimiter: String) -> String? {
guard let upperIndex = (self.range(of: delimiter)?.upperBound) else { return nil }
let trailingString: String = .init(self.suffix(from: upperIndex))
return trailingString
}
}
extension TimeInterval {
var formattedString: String? {
let formatter = DateComponentsFormatter()