struct Phone {
var number: String?
var originalLabel: String?
init(number: String? = nil, originalLabel: String? = nil) {
self.number = number
self.originalLabel = originalLabel
}
}
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 UIKit | |
extension SequenceType { | |
/// flatMap 出我们需要的类型 | |
/// | |
/// - Complexity: O(*M* + *N*), where *M* is the length of `self` | |
/// and *N* is the length of the result. | |
@warn_unused_result | |
public func flatMap<T>(type type: T.Type) -> [T] { | |
return flatMap { $0 as? T } |
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
enum Result<T> { | |
case Success(T) | |
case Failure(ErrorType) | |
} | |
extension Result { | |
static func unit(x: T) -> Result<T> { | |
return .Success(x) | |
} |
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 UIKit | |
func recurisiveSearchParentViewUntil<T: UIView>(type: T.Type, currentView: UIView) -> T? { | |
switch currentView { | |
case let view as T: | |
return view // 当前 view 满足则返回 view | |
case let view where view.superview != nil: | |
return recurisiveSearchParentViewUntil(type, currentView: view.superview!) | |
default: | |
return nil |
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
let CampusNetworkProvider = MoyaProvider<CampusNetwork>(endpointClosure: MoyaProvider.DefaultEndpointMapping, | |
requestClosure: requestClosure, | |
stubClosure: MoyaProvider.NeverStub, | |
manager: MoyaProvider<CampusNetwork>.DefaultAlamofireManager(), | |
plugins: [NetworkLoggerPlugin()]) |
NewerOlder