- Ubuntu 14.04, 16.04, or 16.10
- Open up terminal
- Install core deps:
sudo apt-get install clang libicu-dev git
import RxSwift | |
extension ObservableType { | |
public func mapObject<T: Codable>(type: T.Type) -> Observable<T> { | |
return flatMap { (data) -> Observable<T> in | |
if let data = (data as? (HTTPURLResponse, Data))?.1 { | |
return try self.mapObject(type: type, data: data) | |
} else if let json = (data as? (HTTPURLResponse, Any))?.1 { | |
return try self.mapObjectJSON(type: type, json: json) | |
} else { |
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 3 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-3/ | |
import SwiftUI | |
enum MyViewType: Equatable { | |
case formContainer // main container | |
case fieldContainer // contains a text label + text field | |
case field(Int) // text field (with an associated value that indicates the character count in the field) |
let calendar = Calendar.current | |
let today = calendar.startOfDay(for: Date()) | |
let dayOfMonth = calendar.component(.day, from: today) | |
let daysOfMonth = calendar.range(of: .day, in: .month, for: today)! | |
let weekDaysInMonth = (daysOfMonth.lowerBound ..< daysOfMonth.upperBound) | |
.flatMap { calendar.date(byAdding: .day, value: $0 - dayOfMonth, to: today) } | |
.filter { !calendar.isDateInWeekend($0) } |
import Foundation | |
public class Storage { | |
fileprivate init() { } | |
enum Directory { | |
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud. | |
case documents | |
//Simple Type - Person | |
struct Person: Codable { | |
let name: String | |
let age: Int | |
func getString() -> String { | |
return "Name: \(name), Age: \(age)" | |
} | |
} |
// | |
// CoreDataController.swift | |
// | |
// Created by Keith Harrison http://useyourloaf.com | |
// Copyright (c) 2017 Keith Harrison. All rights reserved. | |
// | |
// Redistribution and use in source and binary forms, with or without | |
// modification, are permitted provided that the following conditions are met: | |
// | |
// 1. Redistributions of source code must retain the above copyright |
<details> <summary>How do I dropdown?</summary> <br> This is how you dropdown.
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
File > New > Project...
Create a Package.swift
file in your root project directory, add dependencies, then run swift package fetch
on the command line in the same directory. We’re not going to run swift build
because it will just complain.