I hereby claim:
- I am vittoriom on github.
- I am vittoriom (https://keybase.io/vittoriom) on keybase.
- I have a public key ASBUDFp_pxp2lM5ComDGpVgo-ZcnQCsgYwx0n6yDOk32CQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
protocol Test { | |
func doStuff() | |
} | |
extension Test { | |
// default protocol implementation | |
func doStuff() { | |
print("Stuff!") | |
} | |
} |
enum State { | |
case Happy | |
case Sad | |
} | |
struct Day { | |
let name: String | |
let state: State | |
} |
// Since in this class we'll use other objects, we define a typealias at the beginning of the file that will have 2 functions: | |
// 1) It will provide an interface for service locators that want to locate dependencies for this object, type-safe, not more and not less | |
// 2) It will show in a readable way what dependencies this object needs | |
typealias ArticleInteractorServiceLocatorInterface = protocol<ArticleRepositoryLocator, ReachabilityLocator> | |
// Then we define a class implementing this protocol, that will get all the default implementations of the protocols it inherits from, for free | |
class ArticleInteractorServiceLocator: ArticleInteractorServiceLocatorInterface { | |
// We can just override the default implementation in this specific service locator! | |
func reachability() -> ReachabilityInterface { | |
return OfflineSimulator() |
import Foundation | |
// Define here your domain-specific events | |
public enum MessageEvent { | |
case YourEvent | |
} | |
public protocol MessageProducer { | |
func addSubscriber(subscriber: MessageConsumer) | |
osascript -e 'tell application "iOS Simulator" to quit' | |
xcrun simctl list devices | grep -v '^[-=]' | grep -v 'unavailable' | cut -d "(" -f2 | cut -d ")" -f1 | xargs -I {} xcrun simctl erase "{}" |
// Playground - noun: a place where people can play | |
// Please see http://ashfurrow.com/blog/protocols-and-swift/ to know what this is all about | |
protocol FoodConsumer { | |
var calorieCount: Double { get set } | |
var hydrationLevel: Double { get set } | |
} | |
protocol Food { | |
//By having a simple generic function we don't have to cast the returned value when we call the method on the food |
- (void)setupAnalytics | |
{ | |
VMDInstrumenter *shared = [VMDInstrumenter sharedInstance]; | |
[shared instrumentSelector:@selector(viewDidAppear:) | |
forInstancesOfClass:[VMBaseViewController class] | |
passingTest:^BOOL(VMBaseViewController *instance) { | |
//You can put whatever test you want here | |
return [instance conformsToProtocol:@protocol(VMTrackableScreen)]; | |
} withBeforeBlock:nil | |
afterBlock:^(VMBaseViewController *instance) { |