Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.
Edit Xcode Scheme and add a pre-action script.
Copy the contents of preaction.sh into the pre-action script box.
| // | |
| // AppDelegate.swift | |
| // pushtest | |
| // | |
| // Created by sawapi on 2014/06/08. | |
| // Copyright (c) 2014年 sawapi. All rights reserved. | |
| // | |
| // iOS8用 | |
| import UIKit |
| import Foundation | |
| var token: dispatch_once_t = 0 | |
| func test() { | |
| dispatch_once(&token) { | |
| println("This is printed only on the first call to test()") | |
| } | |
| println("This is printed for each call to test()") | |
| } |
| extension NSDate { | |
| var stringFormattedAsRFC3339: String { | |
| return rfc3339formatter.stringFromDate(self) | |
| } | |
| class func dateFromRFC3339FormattedString(rfc3339FormattedString:String) -> NSDate? | |
| { | |
| /* | |
| NOTE: will replace this with a failible initializer when Apple fixes the bug | |
| that requires the initializer to initialize all stored properties before returning nil, |
| mr Marathi | |
| bs Bosnian | |
| ee_TG Ewe (Togo) | |
| ms Malay | |
| kam_KE Kamba (Kenya) | |
| mt Maltese | |
| ha Hausa | |
| es_HN Spanish (Honduras) | |
| ml_IN Malayalam (India) | |
| ro_MD Romanian (Moldova) |
| import Foundation | |
| public struct Meter { | |
| fileprivate var value: Double | |
| public init(_ value: Double) { | |
| self.value = value | |
| } | |
| public init(_ value: Int) { |
Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.
Edit Xcode Scheme and add a pre-action script.
Copy the contents of preaction.sh into the pre-action script box.
NSTimer is a great example of an over-verbose, outdated Objective-C API. To run a simple line of code after a delay, you need to write a lot of boilerplate crap.
How about this:
NSTimer.schedule(5.seconds) {
println("Hello world!")
}| import Foundation | |
| let size = MemoryLayout<Int16>.stride | |
| let data = Data(bytes: [1, 0, 2, 0, 3, 0]) // little endian for 16-bit values | |
| let int16s = data.withUnsafeBytes { (bytes: UnsafePointer<Int16>) in | |
| Array(UnsafeBufferPointer(start: bytes, count: data.count / size)) | |
| } | |
| let length = data.count * MemoryLayout<Int16>.stride |
| func ==<U: Equatable, T: protocol<RawRepresentable, Equatable> where T.RawValue == U>(lhs: U, rhs: T) -> Bool { | |
| return lhs == rhs.rawValue | |
| } | |
| func !=<U: Equatable, T: protocol<RawRepresentable, Equatable> where T.RawValue == U>(lhs: U, rhs: T) -> Bool { | |
| return lhs != rhs.rawValue | |
| } |
| import UIKit | |
| extension UIView { | |
| var allSubviews: [UIView] { | |
| subviews + subviews.flatMap { $0.allSubviews } | |
| } | |
| func firstSubview<T: UIView>(of type: T.Type) -> T? { | |
| allSubviews.first { $0 is T } as? T |