Skip to content

Instantly share code, notes, and snippets.

@niwatako
niwatako / CodePiece.txt
Created June 19, 2018 11:20
What's new In Testing #roppongiswift #CodePiece
### こたらさん(@kotala_b) What's new In Testing
VISITSで働いています、4週間目。
WWDCのテストセッションより
#### Target selection
Xcodeのターゲットも設定でそれぞれにコードカバレッジを出力できる、Xcode9.3から使えるようになっている。
### XCCOV
@niwatako
niwatako / CodePiece.txt
Created June 19, 2018 11:11
Measuring Performance Using Logging #roppongiswift #CodePiece
### 関さん(@takasek)Measuring Performance Using Logging
> コードたくさん出てきて記録むずいのでセッションビデオと一緒に見てくれ!!
Measuring Performance Using Logging - WWDC 2018 - Videos - Apple Developer
https://developer.apple.com/videos/play/wwdc2018/405/
os_log というものがあります。WWDC2016から導入された。
2018からsignpost
Instrumentsでパフォーマンス計測に使えるように拡張されて軽いのでどんどん使ってくださいとのこと。
@niwatako
niwatako / CodePiece.swift
Created June 19, 2018 10:59
High Performance Auto Layout #roppongiswift #CodePiece
### 佐藤さん(@hatakenokakashi) High Performance Auto Layout
High Performance Auto Layoutというセッションを振り返ります。
MAMORIO株式会社でiOSエンジニアをしています。
High Performance Auto LayoutはiOS12でAutoLayoutのパフォーマンスが上がったことが紹介されている。
#### Independent Sibling Views
兄弟関係の、View間で関係のないView同士の描画パフォーマンスが改善された。
#### Dependent Sibling Views・Nested Veiws
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// request
NSURL *url = [NSURL URLWithString:@"http://xxx.appspot.com/"];
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData //キャッシュ無視
timeoutInterval:30];
NSURLResponse *response = nil;
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let request = URLRequest(url: URL(string: "http://xxx.appspot.com/")!)
NSURLConnection.sendAsynchronousRequest(request, queue: .main) { response, data, error in
@niwatako
niwatako / CodePiece.swift
Created January 28, 2017 06:11
🍺を流す #love_swift #CodePiece
import UIKit
import PlaygroundSupport
let view = UIView(frame: CGRect(x: 0, y:0, width:320, height:44))
view.backgroundColor = UIColor.black
PlaygroundPage.current.liveView = view
(0...2).forEach {
let sushi = UILabel(frame: CGRect(x: 320, y: 0, width: 44, height: 44))
@niwatako
niwatako / CodePiece.swift
Created January 27, 2017 11:13
protoファイル #tsssmeetup #CodePiece
// .proto ファイル
// これからプログラムを生成したり出来る
// https://github.com/apple/swift-protobuf
message BookInfo {
int64 id = 1;
string title = 2;
string author = 3;
}
@niwatako
niwatako / CodePiece.swift
Created September 14, 2016 12:55
この型パラメーターの T かっこ良くないですか? #CodePiece #iphonekyoto
func get<T: JSONPrimitive>(_ key: String) throws -> T { // この T は型推論で左辺の型になる
guard let value = dictionary[key] else {
throw JSONDecodeError.missingRequiredKey(key)
}
// Int に let number: Int = get("key") とすればここは Int にキャストを試み、失敗したらエラーになる。
guard let typed = value as? T else {
throw JSONDecodeError.unexpectedType(
key: key,
expected: T.self,
actual: type(of: value))
@niwatako
niwatako / CodePiece.swift
Created September 14, 2016 12:49
実際書くと今まで聞いてきたものはだいたいこんな感じにかける。普段書くものでSwift3を書いていけば良いと思う #CodePiece #iphonekyoto
struct ProfileResponse: APIResponse {
let name: String
let age: Int
init(json: JSONObject) throws {
name = try json.get("name")
age = try json.get("age")
}
}
protocol APIEndpoint {
@niwatako
niwatako / CodePiece.swift
Created September 14, 2016 12:11
Package.swift #CodePiece #iphonekyoto
Package(
name: String,
pkgConfig: String? = nil,
providers: [SystemPackageProvider]? = nil, // brew や apt を提案できる。ユーザーに示すだけで実際SwiftPackageManagerが取得代行してくれるわけではない
targets: [Target] = [],
dependencies: [Package.Dependency] = [], // Versionとして指定できるのはセマンティックバージョニングに沿ったタグだけ。
exclude: [String] = []
)
// TestDependencies というテストに必要だが利用者には関係ないパッケージを入れる仕組みが一時あったが無くなった。今後話し合うらしい。