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 | |
var str = "Hello, playground" | |
protocol A { | |
func hello() | |
} | |
protocol B: A { | |
func hello2() |
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 passParam(student: (name: String, address: String, rollNo: String)?, param: (param3: String, param4: String, param5: String, param6: String)?) { | |
print("student is") | |
print(student ?? "Nodata") | |
print("param is") | |
print(param ?? "Nodata") | |
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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
// | |
//class MyViewController : UIViewController { | |
// override func loadView() { | |
// let view = UIView() | |
// view.backgroundColor = .white | |
// |
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
protocol M { | |
func convert(stringInt: [String]) -> [Int] | |
} | |
protocol W { | |
func fetchDays() -> [String] | |
} | |
protocol I { | |
var worker: W? {get set} |
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 ObservableType { | |
func flatMap<A: AnyObject, O: ObservableType>(weak obj: A, selector: @escaping (A, Self.E) throws -> O) -> Observable<O.E> { | |
return flatMap { [weak obj] value -> Observable<O.E> in | |
try obj.map { try selector($0, value).asObservable() } ?? .empty() | |
} | |
} | |
func flatMapFirst<A: AnyObject, O: ObservableType>(weak obj: A, selector: @escaping (A, Self.E) throws -> O) -> Observable<O.E> { | |
return flatMapFirst { [weak obj] value -> Observable<O.E> in |
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 Reactive where Base: UITextField { | |
public func validateWithRegex(value:String) -> ControlProperty<String?> { | |
let original: ControlProperty<String?> = self.text | |
let values: Observable<String?> = original.map { self.validate(text: $0, regex: value) } | |
let valueSink: AnyObserver<String?> = original.mapObserver { $0 } | |
return ControlProperty<String?>(values: values, valueSink: valueSink) | |
} | |
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 | |
@IBDesignable //desinagble in storyboard(view in storyboard) | |
class SampleView: UIView { | |
/* | |
// Only override draw() if you perform custom drawing. | |
// An empty implementation adversely affects performance during animation. | |
override func draw(_ rect: CGRect) { | |
// Drawing code | |
} |