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 MovieData: Codable { | |
let data: Movies | |
} | |
Struct Movies: Codable { | |
let movies: [Movie] | |
} | |
Struct Movie: Codable { | |
let id: Int |
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
{ | |
"data": { | |
"movies": [ { "id": 1, "title": "title", "image_url":"loremipsum"} ] | |
} | |
} |
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 | |
class Test { | |
var username: String? | |
var password: String? | |
var onSuccess: (() -> (Void))? = nil | |
var onFailure: (() -> (Void))? = 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
struct Invoice { | |
private var invoiceId = 0 | |
private var date = Date() | |
private var items = [Item]() | |
private var name = "" | |
private var paid = false | |
private var paymentData: Date? | |
func paid() { | |
paid = true |
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 ViewModelDelegate { | |
func dataLoaded(); | |
} | |
class ViewModel { | |
private var objects: [Object]? | |
var delegate: ViewModelDelegate? | |
func getObjects() { | |
// .. do something fancy in background here |
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 ViewModelDelegate { | |
func dataLoaded(); | |
} | |
class ViewModel { | |
var objects: [Object]? | |
var delegate: ViewModelDelegate? | |
func getObjects() { | |
// .. do something fancy in background here |
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 ProductDataAdapter { | |
private var database: FMDatabase? | |
init() { | |
var paths: [Any] = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) | |
var docsPath: String = paths[0] | |
var path: String = URL(fileURLWithPath: docsPath).appendingPathComponent("abc.sqlite").absoluteString | |
database = FMDatabase(path: path) | |
} |
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
// Converted with Swiftify v1.0.6242 - https://objectivec2swift.com/ | |
class ViewController { | |
override func viewDidAppear(_ animated: Bool) { | |
var paths: [Any] = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) | |
var docsPath: String = paths[0] | |
var path: String = URL(fileURLWithPath: docsPath).appendingPathComponent("abc.sqlite").absoluteString | |
database = FMDatabase(path: path) | |
database.open() |
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
// | |
// ViewController.swift | |
// NullObject | |
// | |
// Created by Suprie on 1/18/16. | |
// Copyright © 2016 Suprie. All rights reserved. | |
// | |
import UIKit |