Skip to content

Instantly share code, notes, and snippets.

View gbasile's full-sized avatar

Giuseppe Basile gbasile

View GitHub Profile
@gbasile
gbasile / ViewModel.swift
Last active April 30, 2021 08:25
ViewModel ViewState generation
import Combine
public extension Publisher where Output: Equatable {
@discardableResult func sink() -> AnyCancellable {
sink(
receiveCompletion: { _ in /* No handling needed */},
receiveValue: { _ in /* No handling needed */ })
}
}
@gbasile
gbasile / Router+protocol.swift
Last active April 28, 2021 10:15
A couple of different approaches for Routers on iOS. (by Alexandros, Kamil, Jader & Giuseppe)
struct NavigatorTypeV2 {}
struct Device {}
protocol Router: class {
var navigator: NavigatorTypeV2 { get }
}
extension Router {
public var navigator: NavigatorTypeV2 { fatalError("Not implemented. This router uses a legacy navigator or custom navigation.") }
}
@gbasile
gbasile / Router+protocol.swift
Created April 28, 2021 10:12
A couple of different approaches for Routers on iOS.
struct NavigatorTypeV2 {}
struct Device {}
protocol Router: class {
var navigator: NavigatorTypeV2 { get }
}
extension Router {
public var navigator: NavigatorTypeV2 { fatalError("Not implemented. This router uses a legacy navigator or custom navigation.") }
}
@gbasile
gbasile / protocol_extensions_caveats.swift
Created June 27, 2018 15:38
Be careful when providing default implementations to your protocols
import Foundation
protocol People {
var eat: String { get } // 1) try to comment this
var dislike: String { get } // 2) Try to comment this
}
//3) Try to rename one of the above
extension People {
@gbasile
gbasile / Fastfile
Created February 13, 2017 17:29
Fastfile Example Novoda
fastlane_version "2.14.2"
default_platform :ios
platform :ios do
desc "Runs all the tests"
lane :test do
scan
end
desc "Runs all the UI tests"
let request = RegisterDeviceTokenRequest(deviceToken:tokenString, callback: { (response: Result) -> Void in
switch response {
case .Success:
DDLogInfo("📩 ✅ Device token registration")
case .Failure(let error):
DDLogError("📩 ❌ Device token registration \(error)")
}
})
NetworkingClient.request(request)
class RegisterDeviceTokenRequest: Request {
convenience init(deviceToken: String, callback: RequestCallback) {
self.init(path: "add_token", parameters: ["token": deviceToken], callback: callback)
}
}
@gbasile
gbasile / gist:5487386
Created April 30, 2013 08:29
Return Code
- (NSString *)score
{
if (self.firstPlayerScore == 3 && self.secondPlayerScore == 3 )
return @"DEUCE";
if (self.firstPlayerScore == 4)
return @"GAME PLAYER 1";
if (self.secondPlayerScore == 4)
return @"GAME PLAYER 2";
@gbasile
gbasile / gist:5487378
Created April 30, 2013 08:27
If/else code
- (NSString *)score
{
NSString *resultScore = nil;
if (self.firstPlayerScore == 3 && self.secondPlayerScore == 3 )
resultScore = @"DEUCE";
else if (self.firstPlayerScore == 4)
resultScore = @"GAME PLAYER 1";
else if (self.secondPlayerScore == 4)
codesign -f -v -s "Developer ID Application: Sharit Application SL" ./libcurl.framework/Versions/A