Skip to content

Instantly share code, notes, and snippets.

@hassanvfx
hassanvfx / swiftLoopProps
Created September 5, 2018 04:18
Swift Loop on Struct Properties
protocol PropertyLoopable
{
func allProperties() throws -> [String: Any]
}
extension PropertyLoopable
{
func allProperties() throws -> [String: Any] {
@hassanvfx
hassanvfx / gist:a4e761e02a62bd9bf90b3bf37ae41e94
Created September 8, 2018 20:25
Print Retain Coun in Swift
print(CFGetRetainCount(object))
////////
/// 11:55
/// ONE and ONE are all equal.
/// FIVE and FIVE fingers all have.
/// Humanity is but god’s hand.
///
/// The lips of wisdom are open.
/// The mirror will soon awake.
/// The time for unity is now.
import UIKit
import RxDataSources
struct MoviesSection {
var header:String
var items:[Item]
var uniqueId: String = "Trending"
}
import UIKit
import ObjectMapper
import SwiftDate
import RxDataSources
struct Genre : Mappable, Codable{
var id:String?
var idInt:Int?
var name:String?
import UIKit
import Delayed
import RxSwift
import RxCocoa
import RxDataSources
protocol MoviesCollectionViewProtocol:AnyObject {
func didSelect(movie : Movie) //todo pass selected index and/or object
}
import UIKit
enum APIEndpoints {
case getMovie(String)
case getMovieRelated(String)
case getTrendingMovies(Int)
func url()->String{
import UIKit
import RxSwift
import Alamofire
import AlamofireObjectMapper
extension Reactive where Base:APIService{
func call<K:APIResponse>(_ endpoint : APIEndpoints) -> Single<K> {
return Single<K>.create { single in
import UIKit
import ObjectMapper
protocol APIResponse {
func items<K>(_ type:K.Type? )->[K]
}
extension APIResponse{
func items<K>(_ type:K.Type? = nil)->[K]{
return ([self] as? [K]) ?? []
import UIKit
import Alamofire
import AlamofireObjectMapper
import ObjectMapper
typealias APIClosure<K> = (K?)->Void
class APIService: NSObject {
static let API_KEY_V3 = "SECRET_KEY"