Swift JSON Object Mappers
Argo
struct User {
let id: Int
let name: String
let email: String?
let role: Role
struct User: Codable, Equatable { | |
@StringDecodable | |
var identifier: Int | |
@StringCodable | |
var anotherID: UInt64 | |
} | |
let user = User(identifier: 100, anotherID: 1030402030) | |
user.anotherID |
class Obj {} | |
class Obj2: Obj {} | |
let item1 = Obj(), item2 = Obj2() | |
if item1.dynamicType === item2.dynamicType { | |
print("Same subclass") | |
} else { | |
print("Different subclass") | |
} |
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) |
struct User {
let id: Int
let name: String
let email: String?
let role: Role
protocol SomeValue { | |
var name: String? { get } | |
func getName() -> String? | |
} | |
extension SomeValue { | |
var name: String? { | |
return nil | |
} | |
func getName() -> String? { |
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 | |
} |
//: 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 |
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 |
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 | |
} |
import Foundation | |
public func SelectTypedItemFromArray<T>(array: [AnyObject]) -> T? { | |
for eachItem in array { | |
if let typedItem = eachItem as? T { | |
return typedItem | |
} | |
} | |
return nil | |
} |