- XML GET
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET "http://hostname/resource"
- JSON GET
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://hostname/resource"
- JSON PUT
// NSScanner+Swift.swift | |
// A set of Swift-idiomatic methods for NSScanner | |
// | |
// (c) 2015 Nate Cook, licensed under the MIT license | |
import Foundation | |
extension NSScanner { | |
// MARK: Strings |
// Copyright (c) 2014 Mark Grimes. All rights reserved. | |
import Foundation | |
class FakeUserDefaults : NSUserDefaults { | |
typealias FakeDefaults = Dictionary<String, AnyObject?> | |
var data : FakeDefaults | |
override init?(suiteName suitename: String) { |
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET "http://hostname/resource"
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://hostname/resource"
import Foundation | |
extension CustomStringConvertible { | |
var description: String { | |
var description: String = "\(type(of: self))(" | |
let selfMirror = Mirror(reflecting: self) | |
for child in selfMirror.children { | |
if let propertyName = child.label { |
// | |
// ContentMapper.swift | |
// | |
// | |
// Created by Antoine van der Lee on 09/03/2021. | |
// | |
import Foundation | |
import ContentKit |
import Foundation | |
final class Sample: NSObject { | |
@objc dynamic var name: String = "" | |
} | |
class MyObj: NSObject { | |
@objc dynamic var test: String = "" | |
} | |
extension NSObjectProtocol where Self: NSObject { |
func testNotifications() { | |
// map all authorizationStatus with expected Result | |
let authorizationStatusMap: [UNAuthorizationStatus: Int] = [.authorized: 1, .denied: 0, .notDetermined: 0, .provisional: 1] | |
UNNotificationSettings.swizzleAuthorizationStatus() | |
authorizationStatusMap.forEach { (key: UNAuthorizationStatus, value: Int) in | |
UNNotificationSettings.fakeAuthorizationStatus = key | |
let mockCenter = UserNotificationCenterMock() | |
let mockCoder = MockNSCoder() |
public struct AnyEquatable: Equatable { | |
private let value: Any | |
private let equals: Any -> Bool | |
public init<E: Equatable>(_ value: E) { | |
self.value = value | |
self.equals = { ($0 as? E == value) ?? false } | |
} | |
} |