Nicholas Maccharoli
github.com/nirma
@din0sr
# Provide $query as a variable. | |
# The query is the same as you would enter into the search field e.g. "org:johndevs in:name feedreader" | |
query GetFilesQuery($branch: GitObjectID, $query: String!) { | |
search(first: 1, type: REPOSITORY, query: $query) { | |
edges { | |
node { | |
... on Repository { | |
object(expression: "master:", oid: $branch) { | |
... on Tree { |
// This sample works on Swift4.2 and Swift5! | |
// Let's try to execute this sample with Playground! | |
import Foundation | |
// - MARK: Artificially RxSwift classes | |
public enum Rx { | |
public final class Observable<E> {} |
// UICollectionView Objective-C example | |
- (void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; | |
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject]; | |
if (selectedIndexPath != nil) { | |
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator; | |
if (coordinator != nil) { | |
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { |
[Mint][1]はSwift Package Managerで作成したコマンドラインツールのインストール、実行、配布を簡単にすることを目的としたツールです。 Homebrewでのformula管理の煩わしさの無さ、同一コマンドをバージョン指定で実行可能というところが売りのようです。
ここでは簡単なコマンドラインツールをSwift Package Managerで作成し、Mintで実行する流れを確認します。 SPMでCLIツールを作る手順を既に知ってる場合は「Mintをインストール」から確認するとよいでしょう。
*.[7z,xz,bzip2,gzip,tar,zip,wim,ar,arj,cab,chm,cpio,cramfs,dmg,ext,fat,gpt,hfs,ihex,iso,lzh,lzma,mbr,.msi,nsis,ntfs,qcow2,rar,rpm,squashfs,udf,uefi,vdi,vhd,vmdk,wim,xar,z] diff=archive |
import Dispatch | |
import Foundation | |
var x = 7 | |
let dd = withUnsafeBytes(of: &x, { DispatchData.init(bytes: $0) }) | |
print(dd as? Data) // Case 1: nil | |
print(dd as? NSData) // Case 2: nil | |
print(dd as Any as? Data) // Case 3: nil | |
print(dd as Any as? NSData) // Case 4: .some | |
print(dd as Any as? NSData as Data?) // Case 5: .some |
Author: Chris Lattner
print("=== signal (hot) ===") | |
do { | |
let (signal, observer) = Signal<Int, NoError>.pipe() | |
let s = signal | |
.map { x -> Int in | |
print("map \(x)") | |
return x | |
} | |
s.observeValues { _ in } |
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.