Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The newest super hissatsu-waza of iOS app devel...
Search
cockscomb
April 15, 2015
Programming
4
3.1k
The newest super hissatsu-waza of iOS app development
Presented at potatotips #16
謝辞
必殺技の名前を考えるのに貢献してくれたyashiganiさんにこの場を借りてお礼申し上げます。
cockscomb
April 15, 2015
Tweet
Share
More Decks by cockscomb
See All by cockscomb
jq at the Shortcuts
cockscomb
1
1.7k
GraphQL放談
cockscomb
4
1.9k
GraphQL Highway
cockscomb
28
8.3k
吉田を支える技術
cockscomb
0
2.2k
コーポレートサイトを静的化してAmplify Consoleにデプロイする
cockscomb
0
3.3k
ユーザインターフェイスと非同期処理
cockscomb
5
1.8k
GUIアプリケーションの構造と設計
cockscomb
10
10k
イカリング2におけるシングルページアプリケーション
cockscomb
2
7.4k
あなたの知らない UIKit の世界 — UITableView に UITextView を置きたい
cockscomb
1
7.4k
Other Decks in Programming
See All in Programming
為你自己學 Python
eddie
0
510
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
750
2025.01.17_Sansan × DMM.swift
riofujimon
1
230
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
410
Androidアプリの One Experience リリース
nein37
0
950
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
210
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
250
Amazon Nova Reelの可能性
hideg
0
140
Findy Team+ Awardを受賞したかった!ベストプラクティス応募内容をふりかえり、開発生産性向上もふりかえる / Findy Team Plus Award BestPractice and DPE Retrospective 2024
honyanya
0
140
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
170
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
113
50k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Six Lessons from altMBA
skipperchong
27
3.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Documentation Writing (for coders)
carmenintech
67
4.5k
Gamification - CAS2011
davidbonilla
80
5.1k
Become a Pro
speakerdeck
PRO
26
5.1k
Making Projects Easy
brettharned
116
6k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
Transcript
ඞࡴ ࠷৽iOSΞϓϦ։ൃɹɹٕ
cockscomb
None
WATCH SPORT 42mm Space Gray Aluminum Case with Black
Sport Band
ඞࡴ ࠷৽iOSΞϓϦ։ൃɹɹٕ
ඞࡴ ΞϯϥοϓϋϦέʔϯ
let intLike = ["12.3", "45", "6-7-8"] let results = intLike.map
{ $0.toInt() } println(results) // => [nil, Optional(45), nil]
let intLike = ["12.3", "45", "6-7-8"] let results = intLike.map
{ $0.toInt() }.filter { $0 != nil }.map { $0! } println(results) // => [45]
let intLike = ["12.3", "45", "6-7-8"] let results = intLike.flatMap
{ $0.toInt().map { [ $0 ] } ?? [] } println(results) // => [45] New in Swift 1.2
ΞϯϥοϓϋϦέʔϯ
ඞࡴ ਅۭΦϖϨʔγϣϯΓ
class DragonOperation: NSOperation { let string: String var result: String?
init(_ string: String) { self.string = string } override var asynchronous: Bool { return true } ... override func start() { if cancelled { internalFinished = true return } internalExecuting = true let queue = dispatch_get_global_queue( QOS_CLASS_UTILITY, 0) dispatch_async(queue) { self.result = self.string.lowercaseString self.internalExecuting = false self.internalFinished = true } } }
private var internalExecuting: Bool = false { willSet { willChangeValueForKey("isExecuting")
} didSet { didChangeValueForKey("isExecuting") } } override var executing: Bool { return internalExecuting } private var internalFinished: Bool = false { willSet { willChangeValueForKey("isFinished") } didSet { didChangeValueForKey("isFinished") } } override var finished: Bool { return internalFinished }
let waza = DragonOperation("Z") waza.completionBlock = { if let result
= waza.result { println(result) // => "z" } } waza.start()
let oraora = ["X", "Y", "Z"].map { DragonOperation($0) } let
queue = NSOperationQueue() dispatch_async(dispatch_queue_create("Hissatsu", nil)) { queue.addOperations(oraora, waitUntilFinished: true) dispatch_sync(dispatch_get_main_queue()) { let results = oraora.flatMap { $0.result.map { [ $0 ] } ?? [] } println(results) // => ["x", "y", "z"] } }
ਅۭΦϖϨʔγϣϯΓ
ඞࡴ ΠχϡϝϨΠτόελʔ
let fonts = "/System/Library/Fonts" let files = NSFileManager().enumeratorAtPath(fonts)! while let
path: AnyObject = files.nextObject() { println(path) }
struct GeneratorOfNSEnumerator<T> : GeneratorType, SequenceType { private let enumerator: NSEnumerator
init(_ enumerator: NSEnumerator) { self.enumerator = enumerator } mutating func next() -> T? { return self.enumerator.nextObject() as! T? } func generate() -> GeneratorOfNSEnumerator<T> { return GeneratorOfNSEnumerator<T>(self.enumerator) } } let fonts = "/System/Library/Fonts" let files = NSFileManager().enumeratorAtPath(fonts)! for path in GeneratorOfNSEnumerator<String>(files) { println(path) }
let fonts = "/System/Library/Fonts" let files = NSFileManager().enumeratorAtPath(fonts)! for path
in files { println(path) } New in Swift 1.2
ΠχϡϝϨΠτόελʔ
ඞࡴ γϟυɾΞΫςΟϏςΟ
let title = "Apple" let URL = NSURL(string: "http://www.apple.com/")! UIActivityViewController(activityItems:
[title, URL], applicationActivities: nil)
class SharableTitle: NSObject, UIActivityItemSource { let title: String? init(title: String?)
{ self.title = title } func activityViewControllerPlaceholderItem( activityViewController: UIActivityViewController) -> AnyObject { return title ?? "" } func activityViewController( activityViewController: UIActivityViewController, itemForActivityType activityType: String) -> AnyObject? { if activityType == UIActivityTypePostToTwitter || activityType == UIActivityTypePostToFacebook { return title } else { return nil } } func activityViewController( activityViewController: UIActivityViewController, subjectForActivityType activityType: String?) -> String { return title ?? "" } }
let title = "Apple" let URL = NSURL(string: "http://www.apple.com/")! UIActivityViewController(
activityItems: [SharableTitle(title: title), URL], applicationActivities: nil)
γϟυɾΞΫςΟϏςΟ
ඞࡴ ΦʔαϜϑΝϯΫγϣϯίʔϧ
class Awesome { func awesome(string: String) -> String { return
string.uppercaseString } } let a = Awesome() Awesome.awesome(a)("Awesome") // => "AWESOME"
class SuperAwesome: Awesome { override func awesome(string: String) -> String
{ return string.lowercaseString } } let s = SuperAwesome() Awesome.awesome(s)("Awesome") // => "awesome"
ΦʔαϜϑΝϯΫγϣϯίʔϧ
ඞࡴ ΞϯϥοϓϋϦέʔϯ ਅۭΦϖϨʔγϣϯΓ ΠχϡϝϨΠτόελʔ γϟυɾΞΫςΟϏςΟ ΦʔαϜϑΝϯΫγϣϯίʔϧ
ඞࡴ ࠷৽iOSΞϓϦ։ൃɹɹٕ