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
######################### | |
# .gitignore file for Xcode4 and Xcode5 Source projects | |
# | |
# Apple bugs, waiting for Apple to fix/respond: | |
# | |
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation? | |
# | |
# Version 2.6 | |
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects | |
# |
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
dispatch_async(dispatch_get_main_queue(), ^{ | |
NSLog(@"3"); | |
}); | |
NSLog(@"1"); | |
[[NSAttributedString alloc] initWithData:[@"<span>html!</span>" dataUsingEncoding:NSUTF8StringEncoding] | |
options:@{ |
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
enum SortOrder { | |
case Ascending, Descending, Same | |
} | |
extension Array { | |
typealias Sorter = (Element, Element) -> SortOrder | |
func sortWithPriorities(sorters: Sorter...) -> Array { | |
return sort { (left, right) -> Bool in | |
for sorter in sorters { | |
switch sorter(left, right) { |
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
public struct EncodableDictionary { | |
typealias EncodingFunction = (inout KeyedEncodingContainer<AnyCodingKey>) throws -> Void | |
// MARK: - Private Properties | |
private var data: [String: Any] = [:] | |
private var encodings: [String: EncodingFunction] = [:] | |
// MARK: - Lifecycle | |
public init() { } | |
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 Notification<T> { | |
let name: NSNotification.Name | |
} | |
private let notificationData = "_notificationData" | |
extension NotificationCenter { | |
func post<T>(_ notification: Notification<T>, object: Any? = nil, data: T) { | |
post(name: notification.name, object: object, userInfo: [notificationData: data]) | |
} |
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
public struct AnyCodable: Codable { | |
public let value: Any? | |
public init(_ value: Any?) { | |
self.value = value | |
} | |
public init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
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 AnyCodingKey: CodingKey { | |
var stringValue: String | |
var intValue: Int? | |
init?(intValue: Int) { | |
self.intValue = intValue | |
self.stringValue = "\(intValue)" | |
} | |
init?(stringValue: String) { | |
self.intValue = 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 Foundation | |
class DictionaryDecoder { | |
init() { } | |
func decode<T: Decodable>(_ type: T.Type, from data: [String: Any]) throws -> T { | |
let decoder = _Decoder(codingPath: [], source: data) | |
return try T(from: decoder) | |
} | |
} |
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 SwiftUI | |
struct ContentView: View { | |
@State var now = Date() | |
@State var showWindow = false | |
@State var text: String = "" | |
let timer = Timer.publish(every: 1, on: .current, in: .common).autoconnect() |
OlderNewer