Skip to content

Instantly share code, notes, and snippets.

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(InformationController.counter), userInfo: nil, repeats: true)
questionArea.textColor = .white
let infoLayer = self.view.layer
infoLayer.cornerRadius = 20.0
infoLayer.borderWidth = 10.0
infoLayer.borderColor = UIColor.white.cgColor
decks
deck_id
deck_description
deck_bg_front
deck_bg_back
deck_price
deck_color
cards
card_name
card_bg
[
{
"id": 0,
"name": "comida",
"price": 0.99,
"description": "this is the description",
"deckImage": "this is a UIImage",
"deckBgImage": "this is a UIImage",
"bought": false,
"cards": [
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
// /Users/mindblown/Library/Developer/CoreSimulator/Devices/335D0FB4-A0FA-4373-8F9D-EC837D3404FC/data/Containers/Data/Application/D9986A43-592F-47E8-9D67-48C2639245E1/Documents
let imagePath = URL(fileURLWithPath: documentsPath + deckName + fileName)
// file:///Users/mindblown/Library/Developer/CoreSimulator/Devices/335D0FB4-A0FA-4373-8F9D-EC837D3404FC/data/Containers/Data/Application/EFEB1A98-30FC-4209-9FF9-20EC640EAA34/Documents/comida/PIA08653~small.jpg
// it creates and extra / in file://
func checkForDecksDirectory() {
let fm = FileManager.default
let dirPath = fm.urls(for: .documentDirectory, in: .userDomainMask)
let docsURL = dirPath[0]
let docPath = docsURL.appendingPathComponent("decks").absoluteString
let deckPath = docsURL.appendingPathComponent("decks")
var isDir : ObjCBool = false
if fm.fileExists(atPath: docPath, isDirectory:&isDir) {
// if directory exists skip
// else
//create directory
createDirectory(name: "cabecao/decks/comida/")
func createDirectory(name: String) {
let fm = FileManager.default
let dirPath = fm.urls(for: .documentDirectory, in: .userDomainMask)
let docsURL = dirPath[0]
[
{
"id": 0,
"name": "comida",
"price": 0.99,
"description": "this is the description",
"deckImage": "https://images-assets.nasa.gov/image/PIA08653/PIA08653~small.jpg",
"deckBgImage": "https://images-assets.nasa.gov/image/PIA08653/PIA08653~small.jpg",
"bought": false,
"cards": [
class BusinessCategory < ApplicationRecord
validates_presence_of :name
has_many :jobs
has_many :business_industries, through: :jobs
end
class UsersController < ApplicationController
def new
@business_categories = BusinessCategory.all
@user = User.new
respond_to do |format|
format.html
format.json { render :json => @business_categories }
end
end
class Job < ApplicationRecord
has_one :user
end