This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isLike = false | |
if isLike { | |
fetchDisLikeAPI() | |
} else { | |
fetchLikeAPI() | |
} | |
isLike = !isLike |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCalss { | |
var resultHandler: CompletionClosure = nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCalss { | |
var resultHandler: CompletionClosure | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias CompletionClosure = (() -> ())? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UITextView { | |
func removeTextPadding() { | |
textContainer.lineFragmentPadding = 0 | |
textContainerInset = .zero | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 移除上下的間距 | |
textView.textContainerInset = .zero | |
// 移除左右的間距 | |
textView.textContainer.lineFragmentPadding = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set textfield max length | |
private var __maxLengths = [UITextField: Int]() | |
extension UITextField { | |
@IBInspectable var maxLength: Int { | |
get { | |
guard let l = __maxLengths[self] else { | |
return Int.max // (global default-limit. or just, Int.max) | |
} | |
return l | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
if isBeingPresented { | |
// start timer | |
} | |
} | |
override func viewWillDisappear(_ animated: Bool) { | |
super.viewWillDisappear(animated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum SectionTypes: CaseIterable { | |
case header | |
case list | |
} | |
print(SectionTypes.allCases.count) // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum SectionType: Int { | |
case header = 0 | |
case list | |
static let count: Int = { | |
var max: Int = 0 | |
while let _ = SectionType(rawValue: max) { max += 1 } | |
return max | |
}() | |
} |