Skip to content

Instantly share code, notes, and snippets.

View marianolatorre's full-sized avatar

Mariano Latorre marianolatorre

View GitHub Profile
@interface MyWindow : UIWindow
@end
@implementation MyWindow
- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
NSSet *tocuhes = [event touchesForWindow:self];
//: Playground - noun: a place where people can play
import UIKit
// arrays are implemented with structs which are value types therefore when assigned they get copied.
let a = [1,2,3,4,5]
var b = a
b.append(6)
print(a)
struct IntStack {
var items = [Int]()
mutating func push(item: Int) {
items.append(item)
}
mutating func pop() -> Int {
return items.removeLast()
}
}
//
// using basic protocols, compliaing to many and static
//
protocol TestProtocol {
var forcedSet: Int { get set }
var noNeedToSet: Int { get }
}
protocol TestTypeProtocol {
func compareGreaterThan(a:Int, b:Int) -> Bool{
return a > b
}
func compareLessThan(a:Int, b:Int) -> Bool{
return a < b
}
func comparator(greaterThan:Bool) -> (Int, Int) -> Bool {
if greaterThan {
@marianolatorre
marianolatorre / HackerRank-30-dictionaries-and-maps.swift
Last active May 25, 2019 13:08
30 days of code: day 8 dictionaries and maps in SWIFT2
import Foundation
func telephones(input : String) {
var map = [String : String]()
let newlineChars = NSCharacterSet.newlineCharacterSet()
let spaceLineChars = NSCharacterSet.whitespaceCharacterSet()
let allLines = input.utf16.split { newlineChars.characterIsMember($0) }.flatMap(String.init)
guard allLines.count > 0 else{