struct User {
let id: Int
let name: String
let email: String?
let role: Role
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 User: Codable, Equatable { | |
@StringDecodable | |
var identifier: Int | |
@StringCodable | |
var anotherID: UInt64 | |
} | |
let user = User(identifier: 100, anotherID: 1030402030) | |
user.anotherID |
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 Obj {} | |
class Obj2: Obj {} | |
let item1 = Obj(), item2 = Obj2() | |
if item1.dynamicType === item2.dynamicType { | |
print("Same subclass") | |
} else { | |
print("Different subclass") | |
} |
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 UIKit | |
let vc = UIViewController() | |
vc.view.backgroundColor = .whiteColor() | |
vc.navigationItem.title = "This is a view controller" | |
let searchController = UISearchController(searchResultsController: nil) | |
//searchController.searchBar.barTintColor = UIColor(red:0.16, green:0.45, blue:0.72, alpha:1) |
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
protocol SomeValue { | |
var name: String? { get } | |
func getName() -> String? | |
} | |
extension SomeValue { | |
var name: String? { | |
return nil | |
} | |
func getName() -> String? { |
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 Swift | |
extension CollectionType where Index: SignedNumberType, Index == Index.Distance { | |
func get(var position: Self.Index) -> Self.Generator.Element? { | |
if position < 0 { | |
position = self.endIndex.advancedBy(position) | |
} | |
return (indices ~= position) ? self[position] : 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
//: Playground - noun: a place where people can play | |
import UIKit | |
infix operator |=| { associativity left } | |
infix operator |=>| { associativity left } | |
infix operator |=<| { associativity left } | |
private func _install(constraint: NSLayoutConstraint) { | |
// Only disable AutoresizineMask on left item, secondItem may need it enabled |
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
Age of Empires II HD | |
Age of Empires® III: Complete Collection | |
Anno 2070™ | |
Aquaria | |
Assassin's Creed® Revelations | |
Banished | |
BioShock™ | |
Borderlands | |
Crysis | |
Crysis 2 - Maximum Edition |
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 func SelectTypedItemFromArray<T, U: SequenceType>(type t: T.Type, array: U) -> T? { | |
for eachItem in array { | |
if let typedItem = eachItem as? T { | |
return typedItem | |
} | |
} | |
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
import Foundation | |
public func SelectTypedItemFromArray<T>(array: [AnyObject]) -> T? { | |
for eachItem in array { | |
if let typedItem = eachItem as? T { | |
return typedItem | |
} | |
} | |
return nil | |
} |
NewerOlder