Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Coding Swift

Alessio Arsuffi alessioarsuffi

👨‍💻
Coding Swift
  • Monk S.r.l.
  • Rome
View GitHub Profile
View gist:09281cb2cce22789de0c755ce061cea8
{
"message" : {}
"vehicle": {
"type": "Car",
"wheels": "4",
"engine": "4000cc"
}
}
{
View DepInjection.swift
//: Playground - noun: a place where people can play
import UIKit
//Everything starts with defining a protocol
protocol Logger {
func log(_ mex: String)
}
//This is one implementation of the protocol
View Framework.podspec
Pod::Spec.new do |s|
...
# Project Settings
s.dependency 'Alamofire'
s.dependency 'RealmSwift', '~> 2.4.4'
...
end
View gist:c0413d9bab9a3bdf3127a2c7ff0576cb
public protocol Entity {
static func primaryKey() -> String?
}
extension NSManagedObject: Entity {
// override into your NSManagedObject subclass
public static func primaryKey() -> String? {
return nil
}
@alessioarsuffi
alessioarsuffi / ArrayTransform.swift
Created May 17, 2016 — forked from Jerrot/ArrayTransform.swift
Transform arrays with ObjectMapper to Realm's List type
View ArrayTransform.swift
// Based on Swift 1.2, ObjectMapper 0.15, RealmSwift 0.94.1
// Author: Timo Wälisch <timo@waelisch.de>
import UIKit
import RealmSwift
import ObjectMapper
import SwiftyJSON
class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType {
typealias Object = List<T>
@alessioarsuffi
alessioarsuffi / gist:64f4a4041d8499f37ff9
Created Oct 27, 2015 — forked from bwhiteley/gist:049e4bede49e71a6d2e2
Initialize Swift subclass of UIView, designed in .xib
View gist:64f4a4041d8499f37ff9
// Create CustomView.xib, set File's Owner to CustomView.
// Link the top level view in the XIB to the contentView outlet.
class CustomView : UIView {
@IBOutlet weak private var contentView:UIView!
// other outlets
override init(frame: CGRect) { // for using CustomView in code
super.init(frame: frame)
self.commonInit()