Skip to content

Instantly share code, notes, and snippets.

View yoxisem544's full-sized avatar
🥑

David Lin yoxisem544

🥑
View GitHub Profile
import Foundation
import SwiftyJSON
public struct Classmate {
// MARK: - Parameters
public let id: Int
public let name: String
public let gender: Gender
public let avatarURL: String
indirect enum LinkedListNode<T> {
case value(element: T, next: LinkedListNode<T>)
case end
}
extension LinkedListNode : Sequence {
typealias Iterator = LinkedListIterator<T>
func makeIterator() -> LinkedListIterator<T> {
import UIKit
indirect enum LinkedListNode<T> {
case value(element: T, next: LinkedListNode<T>)
case end
}
extension LinkedListNode : Sequence {
typealias Iterator = LinkedListIterator<T>
// VIPER template for Xcode code snippet.
// This is not a tipical VIPER arichtecture.
// It's a VIPER with builder, I called it b-viper.
// View is simple.
// Define what will happen on view.
// Like content reload, reviece new data.
// Plug it to view controller.
public protocol <#SomeView#>: class {
// Like, present new content
import UIKit
final public class HitTestExtendedView: UIView {
public weak var reciever: UIView?
public convenience init(withWidth: CGFloat, andRecieverView r: UIView?) {
self.init(frame: CGRect(origin: CGPoint.zero, size: CGSize(width: withWidth, height: withWidth)))
self.reciever = r
@yoxisem544
yoxisem544 / model.swift
Last active June 22, 2017 01:26 — forked from jenhausu/model.swift
MVC
class func loadMessage(complete: (_ objects: Any, error: Error?) -> Void) {
let managerQuery = UserModel.query()!
let userRole = PFRole(withoutDataWithObjectId: "lEGrVrXO0a") // 角色:球場管理
managerQuery.whereKey("userRole", equalTo: userRole)
let caddy = UserModel.current()!
let courseID = caddy.course!
managerQuery.whereKey("course", equalTo: courseID)
import Foundation
extension Array where Element: Comparable {
func quickSort() -> [Element] {
guard let first = self.first else { return [] }
let tail = self.dropFirst()
let lessPart = tail.filter { $0 <= first }.quickSort()
let morePart = tail.filter { $0 > first }.quickSort()
final public class Singleton {
public class func instance() -> Singleton {
struct Static {
static let instance: Singleton = Singleton()
}
return Static.instance
}
import Foundation
final public class Release {
// Add "-D DEBUG" to other swift flag in Build Settings
// ONLY in Debug not in Release!!!!
#if DEBUG
public static let mode = false
#else
public static let mode = true
#endif
struct Person {
var name: String
}
struct Book {
var title: String
var authors: [Person]
var primaryAuthor: Person {
return authors.first!
}