Skip to content

Instantly share code, notes, and snippets.

Avatar

DAO daoseng33

View GitHub Profile
View BadgeBar.swift
import UIKit
public class BadgeBarButtonItem: UIBarButtonItem {
@IBInspectable
public var badgeNumber: Int = 0 {
didSet {
self.updateBadge()
}
}
View ~=.swift
print(0..<200 ~= 159) // true
print(0..<200 ~= 201) // false
View resetUserDefault.swift
let domain = Bundle.main.bundleIdentifier!
UserDefaults.standard.removePersistentDomain(forName: domain)
View toggle.swift
var isLike = false
if isLike {
fetchDisLikeAPI()
} else {
fetchLikeAPI()
}
isLike.toggle()
View isLikeExample.swift
var isLike = false
if isLike {
fetchDisLikeAPI()
} else {
fetchLikeAPI()
}
isLike = !isLike
View CompletionClosureNil.swift
class MyCalss {
var resultHandler: CompletionClosure = nil
}
View CompletionClosureSample.swift
class MyCalss {
var resultHandler: CompletionClosure
}
View TextViewRemovePaddingExtension.swift
extension UITextView {
func removeTextPadding() {
textContainer.lineFragmentPadding = 0
textContainerInset = .zero
}
}