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
# Type a script or drag a script file from your workspace to insert its path. | |
# skip if we run in debug | |
if [ "$CONFIGURATION" == "Debug" ]; then | |
echo "Skip frameworks cleaning in debug version" | |
exit 0 | |
fi | |
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}" | |
# This script loops through the frameworks embedded in the application and |
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
public struct Response<Value> { | |
public let request: URLRequest? | |
public let response: HTTPURLResponse? | |
public let data: Data? | |
public let result: Result<Value> |
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
public typealias NetworkCompletion = ((_ result: Response<Data?>) -> Void)? | |
public enum Method: String { | |
case OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT | |
} | |
public class Request { | |
fileprivate var headers: [String: String] = ["Content-Type": "application/json"] | |
fileprivate var task : URLSessionDataTask! |
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
public typealias JSON = [String: Any] | |
public enum Result<A> { | |
case success(A) | |
case failure(Error) | |
public var isSuccess: Bool { | |
switch self { | |
case .success: | |
return true |
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
fileprivate class SessionDelegate: NSObject, URLSessionDelegate { | |
// MARK: - NSURLSessionDelegate | |
public func urlSession(_ session: URLSession, | |
didReceive challenge: URLAuthenticationChallenge, | |
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) | |
-> Void) { | |
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust && |
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
func unique<S: Sequence, E: Hashable>(_ source: S) -> [E] where E==S.Iterator.Element { | |
var seen: [E:Bool] = [:] | |
return source.filter { seen.updateValue(true, forKey: $0) == nil } | |
} | |
let a = ["four","one", "two", "one", "three","four", "four"] | |
print(unique(a)) | |
struct Person { | |
var name: String |
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
override init(frame: CGRect) { | |
super.init(frame: frame) | |
loadViewFromNib() | |
} | |
required public init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
loadViewFromNib() | |
} |
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: Keyboardable { | |
var layoutConstraintsForKeyboard: [NSLayoutConstraint] { | |
return [layoutBottonTextField] | |
} | |
var addValueForKeyboard: CGFloat { | |
return 0 | |
} | |
} |
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 Keyboardable where Self: UIViewController { | |
public func addKeyboardObservers() { | |
NSNotificationCenter | |
.defaultCenter() | |
.addObserverForName(UIKeyboardWillShowNotification, | |
object: nil, | |
queue: nil) { [weak self] notification in | |
self?.keyboardWillShow(notification) |
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
public protocol Keyboardable { | |
var layoutConstraintsForKeyboard: [NSLayoutConstraint] { get } | |
var addValueForKeyboard: CGFloat { get } | |
func addKeyboardObservers() | |
func removeKeyboardObservers() | |
} |