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
import SwiftUI | |
class AppDelegate: NSObject, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | |
/// your push notification code goes here | |
return true | |
} | |
} |
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 UISearchBar { | |
public var textField: UITextField? { | |
if #available(iOS 13, *) { | |
return searchTextField | |
} | |
let subViews = subviews.flatMap { $0.subviews } | |
guard let textField = (subViews.filter { $0 is UITextField }).first as? UITextField else { | |
return nil | |
} | |
return textField |
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
[ | |
{ | |
"name": "Afghanistan", | |
"dial_code": "+93", | |
"code": "AF" | |
}, | |
{ | |
"name": "Aland Islands", | |
"dial_code": "+358", | |
"code": "AX" |
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 Alamofire.Request { | |
/** Response serializer for images from: http://www.raywenderlich.com/85080/beginning-alamofire-tutorial */ | |
public static func imageResponseSerializer() -> ResponseSerializer<UIImage, NSError> { | |
return ResponseSerializer { request, response, data, error in | |
guard let validData = data else { | |
let failureReason = "Data could not be serialized. Input data was nil." | |
let error = Error.errorWithCode(.DataSerializationFailed, failureReason: failureReason) | |
return .Failure(error) |