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 | |
let defaults = UserDefaults(suiteName: "GistApplication") | |
/// A Property wrapper around UserDefaults which makes it easier to interact with. | |
@propertyWrapper struct UserDefault<T> { | |
/// The key of the entry which should be added to the defaults. | |
let key: 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
import Foundation | |
extension Collection { | |
/// Safe subscription for collection elements. | |
/// | |
/// - Parameter safe: The index of which the element should be returned. | |
/// - Returns: The element at the given index if present, otherwise nil. | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : 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
import UIKit | |
/// A UIView extension to make it easier working with nib and code layouts at the same time. | |
public extension UIView { | |
/// Unarchives the contents of a nib file. | |
/// | |
/// - Returns: The top-level objects in the nib file. | |
class func fromNib<T: UIView>() -> T { | |
return Bundle(for: T.self).loadNibNamed( |
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
# Xcode | |
# | |
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | |
## Build generated | |
build/ | |
DerivedData/ | |
## Various settings | |
*.pbxuser |
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
### Global configuration | |
# Enable rules which are not in the default set | |
opt_in_rules: | |
# - anyobject_protocol # Prefer using `AnyObject` over `class` for class-only protocols. | |
# - array_init # Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. | |
# - attributes # Attributes should be on their own lines in functions and types, but on the same line as variables and imports. | |
- block_based_kvo # Prefer the new block based KVO API with keypaths when using Swift 3.2 or later. | |
- class_delegate_protocol # Delegate protocols should be class-only so they can be weakly referenced. | |
- closing_brace # Closing brace with closing parenthesis should not have any whitespaces in the middle. |
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 SwiftyRSA | |
/// Automatically generated by the Chinese Website. | |
struct AlipayPublicParameter { | |
enum CodingKeys: String, CodingKey { | |
case appID = "app_id" | |
case method | |
case format | |
case charset |
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 SwiftyRSA | |
/// Swift port of the always included _Order_ class from Alipay, because we suffered from the terrible code. | |
/// The code comments went through google translate to give us some hints on what is happening under the hood. | |
/// This struct is used to hold the data for an order within the alipay framework and to get the url parameter | |
/// containing the order object including a RSA signature. | |
private struct LegacyAlipayOrder { | |
/********************************** Pay four elements **********************************/ | |
/// When the merchant signs an agreement with Alipay, Alipay assigns a unique |
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 UserNotifications | |
class NotificationService: UNNotificationServiceExtension { | |
var contentHandler: ((UNNotificationContent) -> Void)? | |
var bestAttemptContent: UNMutableNotificationContent? | |
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { | |
self.contentHandler = contentHandler | |
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) |
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 Logging { | |
/// An Enum that describes the actual Level on which | |
/// Messages should be logged to the console. | |
public enum Level: Int { | |
/// Log all messages. | |
case verbose = 0 | |
/// Log messages of information level and higher. | |
case information = 1 | |
/// Log messages of warning level and higher. | |
case warning = 2 |
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 | |
/// Different Priority Levels for Queue Objects | |
public enum QueuePriority: Int { | |
case low = 0 | |
case medium = 1 | |
case high = 2 | |
/// Returns the priority Type for using the main Queue. | |
fileprivate static func mainQueuePriority() -> QueuePriority { |
NewerOlder