WWDC 2006 2007 2008 2009 2010 2011 2012 2013 2014
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
// | |
// PagerView.swift | |
// | |
// Created by Majid Jabrayilov on 12/5/19. | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
struct PagerView<Content: View>: View { | |
let pageCount: Int |
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 UIKit | |
public extension NSCollectionLayoutAnchor { | |
struct Offset { | |
fileprivate var absolute: CGPoint? | |
fileprivate var fractional: CGPoint? | |
private init(absolute: CGPoint?, fractional: CGPoint?) { | |
self.absolute = absolute | |
self.fractional = fractional |
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 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 |
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
```swift | |
#if swift(>=4.2) | |
print("Swift4.2") | |
#elseif swift(>=4.1) | |
print("Swift4.1") | |
#elseif swift(>=4.0) | |
print("Swift4.0") | |
#elseif swift(>=3.3) | |
print("Swift3.3") | |
#elseif swift(>=3.2) |
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
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 | |
} |
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 | |
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 |
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!")
}
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.
NewerOlder