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 fridaysThe13(forYear:Int) -> [Date]? { | |
| var days = [Date]() | |
| let calendar = Calendar.current | |
| let dateComponentsStart = DateComponents(year: 2017) | |
| let dateStart = calendar.date(from: dateComponentsStart)! | |
| let dateEnd = calendar.date(byAdding: .year, value: 1, to: dateStart) | |
| var comps = DateComponents(day: 13, weekday: 6) |
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
| class Ns:NSObject { | |
| var title: String = "unset" | |
| } | |
| struct Me { | |
| var me:[Ns] { | |
| didSet { | |
| print("set me") | |
| } | |
| } |
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
| (lldb) e let $pin = unsafeBitCast(0x7df67c50, MKPinAnnotationView.self) | |
| (lldb) po $pin |
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 XCPlayground | |
| import UIKit | |
| extension CGSize { | |
| static func aspectFit(aspectRatio : CGSize, newSizeSize: CGSize) -> CGSize { | |
| let mW = newSizeSize.width / aspectRatio.width; | |
| let mH = newSizeSize.height / aspectRatio.height; | |
| var boundingSize = newSizeSize |
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
| /// create a rewindable generator from a collection | |
| /// than previous and next can return you proper Value/Object or nil if it goes past bounds | |
| /// if you find a way to improve it, I'm all ears :-D | |
| struct RewindableGenerator<S : CollectionType where S.Index : BidirectionalIndexType> : GeneratorType, SequenceType { | |
| typealias Sequence = S | |
| private var currentIndex: Sequence.Index | |
| private let prestartIndex: Sequence.Index | |
| private let seq: Sequence |
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
| public extension Int { | |
| /** | |
| Create a random num Int | |
| :param: lower number Int | |
| :param: upper number Int | |
| :return: random number Int | |
| */ | |
| public static func random (#lower: Int , upper: Int) -> Int { | |
| return lower + Int(arc4random_uniform(upper - lower + 1)) | |
| } |
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
| In Xcode, go to the Product menu and choose Edit Scheme. | |
| Select Debug on the left. | |
| Select Arguments on the right. | |
| Under Arguments Passed On Launch, click the add button. | |
| Enter: -com.apple.CoreData.SQLDebug 1 | |
| Click OK. | |
| source and more: http://www.cimgf.com/2013/01/03/nsfetchedresultscontroller-sectionnamekeypath-discussion/#more-1994 |