This file contains 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
struct Car: StringLiteralConvertible { | |
enum CarType: String { | |
case Mercedes, Porsche, Ford, Unknown | |
} | |
var type: CarType | |
typealias ExtendedGraphemeClusterLiteralType = StringLiteralType | |
This file contains 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
#!/bin/sh | |
PROJ=`find . -name '*.xib' -o -name '*.[mh]'` | |
for png in `find . -name '*.png'` | |
do | |
filename=`basename $png` | |
name=${filename%.*} | |
if ! grep -q $name $PROJ; then | |
echo "$png is not referenced" | |
fi |
This file contains 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
- (NSArray *)generate:(int)n randomUniqueNumbersBetween:(int)lowerLimit upperLimit:(int)upperLimit | |
{ | |
NSMutableArray *randomNumberArray = [NSMutableArray arrayWithCapacity:upperLimit-lowerLimit]; | |
// add all numbers to array | |
for (int i = lowerLimit; i < upperLimit; i++) | |
{ | |
[randomNumberArray addObject:@(i)]; | |
} | |
This file contains 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 Parent { | |
var child: Child? { | |
didSet { | |
child.callback = { [weak self] in | |
delegateCallback() | |
} | |
} | |
} | |
This file contains 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 protocol X { | |
func _ok(a: Any) | |
} | |
public protocol StoreSubscriber: X { | |
typealias StoreSubscriberStateType | |
typealias AppStateType | |
func newState(state: StoreSubscriberStateType) |
This file contains 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
struct AIndex: ForwardIndexType { | |
let index: Int | |
func successor() -> AIndex { | |
return AIndex(index: self.index + 1) | |
} | |
} | |
func == (lhs: AIndex, rhs: AIndex) -> Bool { | |
return lhs.index == rhs.index |
This file contains 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
// Benjamin Encz | |
// Note: Proof of Concept, you should definitely not use this! | |
import Cocoa | |
public protocol OptionalType { | |
init() | |
func unwrap() -> Any | |
} |
This file contains 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 struct NonEmptyCollection<T: CollectionType> { | |
let collection: T | |
init?(collection: T) { | |
if !collection.isEmpty { | |
self.collection = collection | |
} else { | |
return nil | |
} |
This file contains 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
// Example of a thing I cannot do with types in Swift | |
struct Operation<Input, Output> { | |
// would also be nice to have a list of operations that yield different types (and be able to dynamically inspect the generic type) | |
var operations: [Operation<>] = [] | |
// This can be accomplished by using type erause | |
// would be nice to be able to leave a type hole here | |
var nextOperation: Operation<Output, _> // second generic argument can be any type from the perspective of this specific type | |
// only important aspect is that input of next operation matches output of this operation |
This file contains 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 Foundation | |
class A { var x = "a" } | |
var a:A = A() | |
isUniquelyReferencedNonObjC(&a) | |
var b = a |