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 ViewController: UIViewController { | |
enum ImageViewState: Int { | |
case open | |
case close | |
var opposite: ImageViewState { | |
switch self { | |
case .open: | |
return .close |
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
struct Address : Codable { | |
var street: String | |
var zipCode: String | |
var city: String | |
var state: String | |
} | |
struct AnyCodingKey : CodingKey { | |
var stringValue: String |
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 MyProtocol { | |
var myName: String { get } | |
init() | |
} | |
struct MyA: MyProtocol { | |
var myName: String { | |
return "My Name is A" |
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 | |
public protocol Groupable { | |
func sameGroupAs(other: Self) -> Bool | |
} | |
extension CollectionType { | |
public typealias ItemType = Self.Generator.Element | |
public typealias Grouper = (ItemType, ItemType) -> Bool |
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 someOptional:Int? = 42 | |
if case .Some(let x) = someOptional{ | |
print("someOptional value is \(x)") | |
} | |
if case let x? = someOptional{ | |
print("someOptional value is \(x)") | |
} | |
let arrayOptionalInts:[Int?] = [nil,1,2,3,nil,5] |
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
struct TableSectionRowInfo { | |
enum RowInfo { | |
case SecOne1 | |
case SecOne2 | |
case SecTwo1 | |
case SecTwo2 | |
case SecTwo3 | |
func rowCount() -> Int { |
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
func map<T, U>(xs: [T], f: T -> U) -> [U] { | |
var result: [U] = [] | |
for x in xs { | |
result.append(f(x)) | |
} | |
return result | |
} |
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
func flatMap<A, B>(x: A?, f: A -> B?) -> B? { | |
if let x = x { | |
return f(x) | |
} else { | |
return nil | |
} | |
} |
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
http://www.raywenderlich.com/90695/modern-core-graphics-with-swift-part-3 |
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 Foundation | |
public func removeObject<T : Equatable>(object: T, inout fromArray array: [T]) | |
{ | |
var index = find(array, object) | |
array.removeAtIndex(index!) | |
} |
NewerOlder