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
3k
Cocoa Kucha Berlin 2013
robb
2
2.1k
ReactiveCocoa NSSpain
robb
18
2.4k
ReactiveCocoa
robb
19
2.7k
Super Mario Masterclass
robb
2
300
Tetris Masterclass
robb
0
510
Other Decks in Programming
See All in Programming
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
910
rails newと同時に型を書く
aki19035vc
5
690
Androidアプリの One Experience リリース
nein37
0
970
ErdMap: Thinking about a map for Rails applications
makicamel
1
100
テストケースの名前はどうつけるべきか?
orgachem
PRO
1
290
Package Traits
ikesyo
1
180
バグを見つけた?それAppleに直してもらおう!
uetyo
0
220
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
270
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
450
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
220
ドメインイベント増えすぎ問題
h0r15h0
2
550
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
180
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
A better future with KSS
kneath
238
17k
Why Our Code Smells
bkeepers
PRO
335
57k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Done Done
chrislema
182
16k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Making the Leap to Tech Lead
cromwellryan
133
9k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
BBQ
matthewcrist
85
9.4k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
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!