Skip to content

Instantly share code, notes, and snippets.

View jolasjoe's full-sized avatar
💭
🧑🏾‍💻

Jolas jolasjoe

💭
🧑🏾‍💻
View GitHub Profile
@baryon
baryon / CopyableLabel.swift
Created February 28, 2019 06:53
CopyableLabel
// Original Source:
// https://stackoverflow.com/questions/1246198/show-iphone-cut-copy-paste-menu-on-uilabel
class CopyableLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
self.sharedInit()
}
@budidino
budidino / string-truncate.swift
Last active April 3, 2024 20:11 — forked from vicc/string-truncate.swift
String truncate extension for Swift 4
extension String {
/*
Truncates the string to the specified length number of characters and appends an optional trailing string if longer.
- Parameter length: Desired maximum lengths of a string
- Parameter trailing: A 'String' that will be appended after the truncation.
- Returns: 'String' object.
*/
func trunc(length: Int, trailing: String = "…") -> String {
return (self.count > length) ? self.prefix(length) + trailing : self
protocol StringType {
var isEmpty: Bool { get }
}
extension String : StringType { }
extension Optional where Wrapped: StringType {
var isNullOrEmpty: Bool {
return self?.isEmpty ?? true
}