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
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 |
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
indirect enum LinkedListNode<T> { | |
case value(element: T, next: LinkedListNode<T>) | |
case end | |
} | |
extension LinkedListNode : Sequence { | |
typealias Iterator = LinkedListIterator<T> | |
func makeIterator() -> LinkedListIterator<T> { |
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
import UIKit | |
indirect enum LinkedListNode<T> { | |
case value(element: T, next: LinkedListNode<T>) | |
case end | |
} | |
extension LinkedListNode : Sequence { | |
typealias Iterator = LinkedListIterator<T> |
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
// 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 |
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
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 |
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 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) | |
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
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() | |
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
final public class Singleton { | |
public class func instance() -> Singleton { | |
struct Static { | |
static let instance: Singleton = Singleton() | |
} | |
return Static.instance | |
} |
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
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 |
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 Person { | |
var name: String | |
} | |
struct Book { | |
var title: String | |
var authors: [Person] | |
var primaryAuthor: Person { | |
return authors.first! | |
} |