This file contains hidden or 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
| [{"name":"Afghanistan","flag":"🇦🇫","code":"AF","dial_code":"+93"},{"name":"Åland Islands","flag":"🇦🇽","code":"AX","dial_code":"+358"},{"name":"Albania","flag":"🇦🇱","code":"AL","dial_code":"+355"},{"name":"Algeria","flag":"🇩🇿","code":"DZ","dial_code":"+213"},{"name":"American Samoa","flag":"🇦🇸","code":"AS","dial_code":"+1684"},{"name":"Andorra","flag":"🇦🇩","code":"AD","dial_code":"+376"},{"name":"Angola","flag":"🇦🇴","code":"AO","dial_code":"+244"},{"name":"Anguilla","flag":"🇦🇮","code":"AI","dial_code":"+1264"},{"name":"Antarctica","flag":"🇦🇶","code":"AQ","dial_code":"+672"},{"name":"Antigua and Barbuda","flag":"🇦🇬","code":"AG","dial_code":"+1268"},{"name":"Argentina","flag":"🇦🇷","code":"AR","dial_code":"+54"},{"name":"Armenia","flag":"🇦🇲","code":"AM","dial_code":"+374"},{"name":"Aruba","flag":"🇦🇼","code":"AW","dial_code":"+297"},{"name":"Australia","flag":"🇦🇺","code":"AU","dial_code":"+61"},{"name":"Austria","flag":"🇦🇹","code":"AT","dial_code":"+43"},{"name":"Azerbaijan","flag":"🇦🇿","code":"AZ","dial_code":"+9 |
This file contains hidden or 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
| struct Contact: Codable, CustomStringConvertible { | |
| var id: String | |
| @NestedKey | |
| var firstname: String | |
| @NestedKey | |
| var lastname: String | |
| @NestedKey | |
| var address: String | |
| enum CodingKeys: String, NestableCodingKey { |
This file contains hidden or 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
| private func changeFrame(label: UILabel, | |
| toOriginX newOriginX: CGFloat, | |
| toOriginY newOriginY: CGFloat, | |
| toWidth newWidth: CGFloat, | |
| toHeight newHeight: CGFloat, | |
| duration: TimeInterval) { | |
| let oldFrame = label.frame | |
| let newFrame = CGRect(x: newOriginX, y: newOriginY, width: newWidth, height: newHeight) | |
| let translation = CGAffineTransform(translationX: newFrame.midX - oldFrame.midX, y: newFrame.midY - oldFrame.midY) |
This file contains hidden or 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 ViewController { | |
| @objc func adjustForKeyboard(notification: Notification) { | |
| let userInfo = notification.userInfo! | |
| let keyboardScreenEndFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue | |
| let keyboardViewEndFrame = view.convert(keyboardScreenEndFrame, from: view.window) | |
| if notification.name == UIResponder.keyboardWillHideNotification { | |
| scrollView.contentInset = UIEdgeInsets.zero | |
| } else { |
This file contains hidden or 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 String { | |
| public var isEmail: Bool { | |
| let dataDetector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) | |
| let firstMatch = dataDetector?.firstMatch(in: self, options: NSRegularExpression.MatchingOptions.reportCompletion, range: NSRange(location: 0, length: length())) | |
| return (firstMatch?.range.location != NSNotFound && firstMatch?.url?.scheme == "mailto") | |
| } | |
| } |
This file contains hidden or 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
| @objc func tapLabel(gesture: UITapGestureRecognizer) { | |
| let text = (gesture.view as? UILabel)?.text ?? "" | |
| let termsRange = (text as NSString).range(of: "terms") | |
| let privacyRange = (text as NSString).range(of: "privacy") | |
| if gesture.didTapAttributedTextInLabel(label: guildLabel, inRange: termsRange) { | |
| print("Tapped terms") | |
| } else if gesture.didTapAttributedTextInLabel(label: guildLabel, inRange: privacyRange) { | |
| print("Tapped privacy") | |
| } else { |
This file contains hidden or 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
| // Method 1 | |
| extension UIViewController { | |
| func topMostViewController() -> UIViewController { | |
| if let presented = self.presentedViewController { | |
| return presented.topMostViewController() | |
| } | |
| if let navigation = self as? UINavigationController { | |
| return navigation.visibleViewController?.topMostViewController() ?? navigation |
This file contains hidden or 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
| import RealmSwift | |
| import Realm | |
| protocol CascadeDeleting: class { | |
| func delete<S: Sequence>(_ objects: S, cascading: Bool) where S.Iterator.Element: Object | |
| func delete<Entity: Object>(_ entity: Entity, cascading: Bool) | |
| } | |
| extension Realm: CascadeDeleting { |
NewerOlder