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
Objective-C Bootcamp
Search
Kazuki Sakamoto
July 19, 2012
Technology
2
57
Objective-C Bootcamp
Kazuki Sakamoto
July 19, 2012
Tweet
Share
Other Decks in Technology
See All in Technology
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
170
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
390
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
130
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
OTelCol_TailSampling_and_SpanMetrics
gumamon
1
170
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
130
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
GraphQLとの向き合い方2022年版
quramy
43
13k
Rails Girls Zürich Keynote
gr2m
94
13k
How GitHub (no longer) Works
holman
310
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Embracing the Ebb and Flow
colly
84
4.5k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Transcript
Objective-C Bootcamp
“Objective-C!” “Objective-C!”
จ๏ (Syntax)
จ๏ (Syntax) •Cݴޠͱಉ͡
จ๏ (Syntax) •Cݴޠͱಉ͡
จ๏ (Syntax) •C / C++ ͱಉډՄೳ
จ๏ (Syntax) •C / C++ ͱಉډՄೳ •Ϋϥε •ϝιουݺͼग़͠
Ϋϥε
Ϋϥε class Foo { int bar; int add(int n) {
bar += n; return bar; } };
Ϋϥε C/C++ͱಉډՄೳ = C++ͱҟͳΔ
Ϋϥε @interface Foo @end
Ϋϥε @interface Foo { int bar; } @end
Ϋϥε @interface Foo { int bar; } - (int)add:(int)n; @end
Ϋϥε @interface Foo { int bar; } - (int)add:(int)n; +
(id)fooWithValue:(int)value; @end
Ϋϥε @implementation Foo @end
Ϋϥε @implementation Foo - (int)add:(int)n { bar += n; return
bar; } @end
ϝιουݺͼग़͠ $foo->add(5);
ϝιουݺͼग़͠ foo.add(5);
ϝιουݺͼग़͠ C/C++ͱಉډՄೳ = CͱҟͳΔ
ϝιουݺͼग़͠ [foo add:5];
ϝιουݺͼग़͠ [[[Foo alloc] init] add:5];
ϝιουݺͼग़͠ $foo = null; $foo->bar();
ϝιουݺͼग़͠ $foo = null; $foo->bar();
ϝιουݺͼग़͠ id foo = nil; [foo bar];
ϝιουݺͼग़͠ id foo = nil; [foo bar]; ʘ ฏؾ ʗ
ϝιουݺͼग़͠ [foo bar];
ϝιουݺͼग़͠ [foo bar]; objc_msgSend(foo, @selector(bar));
ϝιουݺͼग़͠ objc_msgSend Objective-C Message Send ϝοηʔδૹ৴
ϝοηʔδૹ৴ ϝιουݺͼग़͠ •ͲͷΦϒδΣΫτʹ •ͲΜͳϝοηʔδΛૹ͍͍ͬͯ
[duck quack]; [dog quack]; [cat performSelector: NSSelectorFromString(@”quack”)];
ϝοηʔδૹ৴ ϝιουݺͼग़͠ •ͲͷΦϒδΣΫτʹ •ͲΜͳϝοηʔδΛૹ͍͍ͬͯ ɹɹɹɹ Late binding
ϝοηʔδૹ৴ ϝιουݺͼग़͠ Duck Typing (Late binding) ΞώϧͷΑ͏ʹ໐͘ͷͳΒɺ ͦΕΞώϧͰ͋Δ
ϝοηʔδૹ৴ ϝιουݺͼग़͠ Duck Typing (Late binding) ΞώϧͷΑ͏ʹ໐͘ͷͳΒɺ ͦΕΞώϧͰ͋Δ
Objective-C • Early binding • Cؔݺग़ / C++ϝιουݺग़ • Late
binding • Objective-C ϝοηʔδૹ৴
Objective-C • Early binding • Cؔݺग़ / C++ϝιουݺग़ • ߴ
• Late binding • Objective-C ϝοηʔδૹ৴ •
Ϧςϥϧ
Ϧςϥϧ จࣈྻ @”Hello World”
Ϧςϥϧ ”Hello World” จࣈྻ @”Hello World” C / C++ ͱಉډՄೳ
Ϧςϥϧ จࣈྻ @”Hello World” [NSString stringWithUTF8String:”Hello World”]
Ϧςϥϧ @15
Ϧςϥϧ @15 [NSNumber numberWithInt:15]
Ϧςϥϧ ྻ @[a, b, c]
Ϧςϥϧ ྻ @[a, b, c] [NSArray arrayWithObjects:a, b, c, nil]
Ϧςϥϧ σΟΫγϣφϦ @{k1:v1, k2:v2, k3:v3}
Ϧςϥϧ σΟΫγϣφϦ @{k1:v1, k2:v2, k3:v3} NSDictionary
ϝϞϦཧ
ϝϞϦཧ ΦϒδΣΫτͷੜํ๏
ϝϞϦཧ NSString *string = [NSString stringWithFormat:@”Hello %d”, i];
ϝϞϦཧ NSObject *obj = [[NSObject alloc] init];
ϝϞϦཧ id obj = [[NSObject alloc] init];
ϝϞϦཧ ΦϒδΣΫτͷഁغํ๏
ϝϞϦཧ ͳ͠!
ϝϞϦཧ NSObject *obj = [[NSObject alloc] init]; obj = nil;
ϝϞϦཧ • ࢀরΧϯτํࣜ
None
None
None
None
None
None
None
None
None
ϝϞϦཧ • ࢀরΧϯτํࣜ • ੲखಈͰͬͯͨ NSObject *obj = [[NSObject alloc]
init]; [obj release];
ϝϞϦཧ • ࢀরΧϯτํࣜ • ੲखಈͰͬͯͨ • ࠓίϯύΠϥ͕ͬͯ͘ΕΔ! NSObject *obj =
[[NSObject alloc] init]; [obj release];
ϝϞϦཧ • ࢀরΧϯτํࣜ • ίϯύΠϥ͕ͬͯ͘ΕΔ • Automatic Reference Counting •
ུͯ͠ARC
ϝϞϦཧ GCͱҧ͏ͷ?
ϝϞϦཧ • GC • ͍Ζ͍Ζํࣜ͋Δ͕ɺ جຊతʹϥϯλΠϜίετ͕͔͔Δ • ࢀরΧϯτํࣜ • جຊతʹϥϯλΠϜίετ͔͔Βͳ͍
• ॥ࢀর
None
॥ࢀরճආํ๏
॥ࢀরճආํ๏ __weak
__weak id __weak obj = [[NSObject alloc] init];
__weak id __weak obj = [[NSObject alloc] init]; NSLog(@”obj =
%@”, obj);
__weak id __weak obj = [[NSObject alloc] init]; NSLog(@”obj =
%@”, obj); ݁Ռ: (null)
None
εϨου
εϨου Grand Central Dispatch Blocks
εϨου dispatch_queue_t q = dispatch_get_global_queue(0, 0); dispatch_async(q, ^{ ʘ εϨου
ʗ });
εϨου dispatch_queue_t q = dispatch_get_global_queue(0, 0); dispatch_async(q, ^{ ʘ εϨου
ʗ });
εϨου dispatch_queue_t q = dispatch_get_global_queue(0, 0); dispatch_async(q, ^{ ʘ εϨου
ʗ });
εϨου dispatch_async(q, ^{ εϨου্Ͱ࡞ۀ dispatch_async(dispatch_get_main_queue(),^{ ʘϝΠϯεϨουʗ }); });
εϨου • Grand Central Dispatch (GCD) • OS X kernelͷGCD༻εϨουΛ͏ͷ
Ͱܰྔ • API͕؆୯ • LinuxͰ͑ΔΑ!
εϨου • Blocks • lambda, closure • CoffeeScriptͳΒ ->, =>
• C#ͳΒ ()=> • PHP5.3Ҏ߱ function(){} • LinuxͰ͑ΔΑ!
None
“AndroidͰObjective-CͳΜ͡Όʔ!” “Objective-CͳΜ͡Όʔ!” ͓ΘΓ
ຊ