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 View { | |
func badge(num: Int) -> some View { | |
return self.overlay( | |
// ZStack(alignment: .topTrailing) { | |
Circle() | |
.fill(Color.red) | |
.frame(width: 24, height: 24) | |
.overlay(Text(num.description)) | |
.transition(.scale) | |
.alignmentGuide(.trailing) { dim -> CGFloat 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
switch(firstObject, secondObject) { | |
case (is FirstClass, is FirstClass): return true | |
case (is FirstClass, is SecondClass): return false | |
.... | |
} |
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 rndStrings = ["a", "b", "c"] | |
var rndInts = [Int]() | |
rndStrings.forEach { rndString in | |
someAsyncMethod { intResult in | |
rndInts.append(intResult) | |
} | |
} | |
// i want to wait until rndInts has all 3 values |
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 mergeStrings(a: String, b: String) -> String { | |
var mergedString = "" | |
let longString = a.count > b.count ? a : b | |
let shortString = a == longString ? b : a | |
for (indexShortString, character) in shortString.enumerated() { | |
mergedString += "\(character)" | |
let indexLongString = longString.index(longString.startIndex, offsetBy: indexShortString) | |
mergedString += "\(longString[indexLongString])" |
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 = """ | |
{ | |
"report":[ | |
{ | |
"enrollment": "rit2011001", | |
"name": "Julia", | |
"subject":[ | |
{ |
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 class MyMoyaProvider<Target>: MoyaProvider<Target> where Target: Moya.TargetType { | |
override init(endpointClosure: @escaping EndpointClosure = MoyaProvider.defaultEndpointMapping, | |
requestClosure: @escaping RequestClosure = MoyaProvider.defaultRequestMapping, | |
stubClosure: @escaping StubClosure = MoyaProvider.neverStub, | |
callbackQueue: DispatchQueue? = nil, | |
manager: Manager = MoyaProvider<Target>.defaultAlamofireManager(), | |
plugins: [PluginType] = [], | |
trackInflights: Bool = false) { |
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 Polite { | |
func sayHello() | |
} | |
class Test: Polite { | |
} | |
So from here i dont want to see: | |
Test().sayHello() |
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 UIView { | |
func translatesAutoresizingMaskIntoConstraints(value: Bool) { | |
translatesAutoresizingMaskIntoConstraints = value | |
subviews.map { $0.translatesAutoresizingMaskIntoConstraints(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
class CarListViewController: UIViewController { | |
var presenter: CarListPresenter! | |
@IBOutlet weak var tableView: UITableView! | |
private var dataSource: CarListDataSource! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
dataSource = CarListDataSource() | |
tableView.dataSource = dataSource | |
tableView.registerNib(UINib(nibName: CarListTableViewCell.reuseIdentifier, bundle: nil), forCellReuseIdentifier: CarListTableViewCell.reuseIdentifier) |
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
class CarWireframe { | |
private var storyboard : UIStoryboard { | |
return UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) | |
} | |
func getRootNavigationController() -> UINavigationController { | |
let rootViewController = storyboard.instantiateViewControllerWithIdentifier("CarListViewControllerIdentifier") as! CarListViewController | |
rootViewController.carListPresenter = ServiceLocator.instance.getPresenterForCarList(rootViewController, wireframe: self) |