This file contains hidden or 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
| @interface ViewController | |
| @property (nonatomic, weak) IBOutlet UILabel *numberLabel; | |
| @property (nonatomic, strong) NSTimer *numberTimer; | |
| @property (nonatomic, assign) double value; | |
| @property (nonatomic, assign) BOOL cancelTimer; | |
| @property (nonatomic, assign) NSTimeInterval timeInterval; | |
| - (void)updateNumberLabel; | |
| - (void)stopTimer; |
This file contains hidden or 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
| func executeFetchRequestT<T:AnyObject>(request:NSFetchRequest, managedObjectContext:NSManagedObjectContext, error: NSErrorPointer = nil) -> [T]? { | |
| var localError: NSError? = nil | |
| if let results:[AnyObject] = managedObjectContext.executeFetchRequest(request, error: &localError) { | |
| if results.count > 0 { | |
| if results[0] is T { | |
| let asT:[T] = results as [T] | |
| return .Some(asT) | |
| } |
This file contains hidden or 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 CoreData | |
| @objc(_PersistentStoreDescription) private protocol AnyPersistentStoreDescription: NSObjectProtocol, NSCopying { | |
| var type: String { get set } | |
| var configuration: String? { get set } | |
| @objc(URL) var url: URL? { get set } | |
| var options: [String : NSObject] { get } | |
| func setOption(_ option: NSObject?, forKey key: String) |
This file contains hidden or 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 zlib | |
| extension Array where Element == UInt8 { | |
| func adler32() -> UInt32 { | |
| let a1 = zlib.adler32(0, nil, 0) | |
| let size = self.count | |
| let result = self.withUnsafeBytes { (p1: UnsafeRawBufferPointer) -> UInt32 in |
This file contains hidden or 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
| extension Array { | |
| /// Chunk an array in to an array of arrays of the provided size (or smaller) | |
| /// - Parameters: | |
| /// - size: the size of the chunk | |
| /// - Returns: An array of arrays of `Element` | |
| func chunked(into size: Int) -> [[Element]] { | |
| return Swift.stride(from: 0, to: self.count, by: size).map { | |
| Array(self[$0 ..< Swift.min($0 + size, self.count)]) | |
| } | |
| } |
This file contains hidden or 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
| extension Collection { | |
| func random(pick: Int) -> [Element] { | |
| return self.indices.shuffled().prefix(pick).map { self[$0] } | |
| } | |
| } |
This file contains hidden or 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 CustomDatePickerExample: View { | |
| @Binding private var currentDate: Date | |
| @State private var currentYear: Int | |
| @State private var currentMonth: Int | |
| var body: some View { |
This file contains hidden or 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
| <key>User Defined</key> | |
| <dict> | |
| <key>Insert New Line Above Current Line</key> | |
| <string>moveUp:, moveToEndOfParagraph:, insertParagraphSeparator:</string> | |
| <key>Insert New Line Below Currnt Line</key> | |
| <string>moveToEndOfParagraph:, insertParagraphSeparator:</string> | |
| <key>Duplicate Current Line Down</key> | |
| <string>selectParagraph:, delete:, yank:, moveToBeginningOfParagraph:, yank:, moveUp:, moveToEndOfParagraph:</string> | |
| </dict> |
This file contains hidden or 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
| # update with the path to your file, | |
| # /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist | |
| KEYBINDINGSET='IDETextKeyBindingSet.plist' | |
| plutil -insert 'User Defined' -dictionary -- "$KEYBINDINGSET" | |
| # ^⇧⏎ | |
| plutil -insert 'User Defined'.'Insert New Line Above Current Line' -string 'moveUp:, moveToEndOfParagraph:, insertParagraphSeparator:' -- "$KEYBINDINGSET" | |
| # ^⌥⏎ | |
| plutil -insert 'User Defined'.'Insert New Line Below Currnt Line' -string 'moveToEndOfParagraph:, insertParagraphSeparator:' -- "$KEYBINDINGSET" | |
| # ⌘D |
OlderNewer