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
Underscore.m + Asterism
Search
Robert Böhnke
August 21, 2013
Programming
4
1.2k
Underscore.m + Asterism
My talk on Underscore.m and Asterism for CocoaHeads Berlin
Robert Böhnke
August 21, 2013
Tweet
Share
More Decks by Robert Böhnke
See All by Robert Böhnke
Brooklyn iOS Developer Meetup February 2014
robb
8
2.9k
Cocoa Kucha Berlin 2013
robb
2
2.1k
ReactiveCocoa NSSpain
robb
18
2.4k
ReactiveCocoa
robb
19
2.7k
Super Mario Masterclass
robb
2
290
Tetris Masterclass
robb
0
510
Other Decks in Programming
See All in Programming
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
受け取る人から提供する人になるということ
little_rubyist
0
230
Arm移行タイムアタック
qnighy
0
320
C++でシェーダを書く
fadis
6
4.1k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
290
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Quine, Polyglot, 良いコード
qnighy
4
640
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Building Adaptive Systems
keathley
38
2.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Fireside Chat
paigeccino
34
3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Ruby is Unlike a Banana
tanoku
97
11k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
4 Signs Your Business is Dying
shpigford
180
21k
How to Ace a Technical Interview
jacobian
276
23k
Transcript
[email protected]
github.com/robb
Let's talk about
Let's talk about Objective-C
Let's talk about Objective-C talk about
[ ]
transitionFromViewController: toViewController: duration: options: animations: completion:
videoComposition: shouldContinueValidatingAfter FindingInvalidTrackIDInInstruction: layerInstruction: asset:
predicateWithLeftExpression: rightExpression: modifier: type: helpMe: iAmTrappedInAMethodFactory: options:
//
new Grapefruit(0, 10);
[CHGrapefruit grapefruitWithSeeds:0 tastiness:10];
duh!
[NSDictionary dictionaryWithObjectsAndKeys:value, key, nil];
@{ key: value }
enumerateObjectsUsingBlock:
enumerateKeysAndObjectsUsingBlock:
each?
map?
reduce?
filter?
Underscore.m
inspired by underscore.js
not trying to turn Objective-C into JavaScript
not trying to turn Objective-C into JavaScript though it looks
kinda like it…
DSL for data manipulation
Underscore.wrap(array) .filter(^(id obj) { return [obj tastiness] > 8; })
.map(^(id obj) { return [obj juice]; }) .unwrap;
wtf?
@property USDictWrapper *(^map)(USMapBlock block);
foo.method1().method2();
// Nocilla stubRequest(@"GET", @"https://api.example.com") .withHeader(@"Accept", @"application/json");
// Expecta expect(CocoaHeads).to.beFun();
but
- (NSDictionary *)us_map:(USMapBlock block);
[[dictionary us_map:^(id key, id value) { return …; }] us_filter:^(id
object) { return …; }];
Check out BlocksKit
DSL
github.com/robb/Underscore.m
Asterism
Underscore.dictWrap(dictionary).map(block).unwrap; Underscore.arrayWrap(array).map(block).unwrap;
Underscore.dictMap(dictionary, block); Underscore.arrayMap(array, block);
Underscore.dictEach(dictionary, block); Underscore.arrayEach(array, block);
Asterism
__attribute__((overloadable))
ASTEach(NSArray *array, void(^block)(id obj)); ASTEach(NSArray *array, void(^block)(id obj, NSUInteger idx));
ASTEach(NSSet *set, void(^block)(id obj)); …
github.com/robb/Underscore.m github.com/robb/Asterism
thanks!