Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Swi$䛷䛾iOS䜰䝥䝸㛤Ⓨ 
2014ᖺ9᭶ 
䜖䜑䜏㻌᳃ୗ㻌೺ 
㻝
⮬ᕫ⤂௓ 
• 
mokemokechicken 
@{Twi6er, 
Facebook, 
Github, 
Qiita} 
• ᰴᘧ఍♫䜖䜑䜏㻌2014ᖺᗘCTO 
௵ᮇ䛿1ᖺ䛺䛾䛷䛩 
• タィ/䜲䞁䝣䝷/䝃䞊䝞䝃䜲䝗/iOS 
䛜୺ ...
♫ෆPJ䛷ᬤ䛺䛸䛝䛻 
䛣䜣䛺䜰䝥䝸䜢స䛳䛶䜎䛧䛯 
(䜎䛰⤊䜟䛳䛶䛺䛔…) 
• Ꮚ౪ྥ䛡䜰䝥䝸 
• 䜋䜌Swi$䛷 
• Core 
Data䜒฼⏝ 
䛣䛾㛤Ⓨ䜢㏻䛧䛶ᚓ䛯䛣䛸䜢௒᪥䛿䛤⤂௓䛧䜎䛩 
㻟
Swi$䛾㉸ᇶᮏ 
㻠
Swi$䛿䝰䝎䞁䛺ゝㄒ 
୙ኚ䛺ኚᩘ䜔Object䜢స䜜䜛 
ᆺ᥎ㄽ䛻䜘䜛䝇䝖䝺䝇䛾ᑡ䛺䛔䝁䞊䝕䜱䞁䜾 
㛵ᩘᆺゝㄒ䛾≉ᚩ䜢ᣢ䛴 
Generics䛒䜚䜎䛩 
CocoaPods 
䜒౑䛘䜛䜘 
⤮ᩥᏐ䜒ኚᩘ䞉㛵ᩘྡ䛻౑䛘䜎䛩(^^; 
㻡
୙ኚ䛺ኚᩘ䜔Object䜢స䜜䜛 
var 
䛿෌௦ධྍ⬟䛺ኚᩘ 
let 
䛿෌௦ධ୙ྍ⬟䛺ᐃᩘ 
䜶䝷䞊䛻䛺䜛 
㻢
ᆺ᥎ㄽ䛻䜘䜛䝇䝖䝺䝇䛾ᑡ䛺䛔䝁䞊䝕䜱䞁䜾 
ᆺ䛜ྑ㎶䛺䛹䛛䜙᥎ 䛷䛝䜛ሙྜ䛿┬␎ྍ⬟ 
┬␎OK 
↓㥏䛰䛧䛽 
㻣
㛵ᩘᆺゝㄒ䛾≉ᚩ䜢ᣢ䛴 
㛵ᩘ䜢ᘬᩘ䛻ྲྀ䜜䜛 
䠄䝣䜯䞊䝇䝖䜽䝷䝇㛵ᩘ䛷䛒䜛䠅 
䕔 
䛱䜗䛳䛸౽฼ 
᭱ᚋ䛾ᘬᩘ䛜㛵ᩘ䛺䜙 
䜹䝑䝁䜢㛢䛨䛶䛛䜙Closure䜢᭩䛟䛣䛸䜒䛷䛝䜛 
䜒䛿䜔Blocks䛿 
ྂ௦ㄒ㨱⾡ 
㻤
኱஦䛺ゝㄒ௙ᵝ 
䛔䛟䛴䛛 
Pickup䛩䜛䜘 
㻥
Module 
• 䝁䞊䝗䜢㓄ᕸ䛩䜛༢఩ 
• ‘import’ 
䛷௚䛾Module䜢ཧ↷䛷䛝䜛 
• Framework䜔ApplicaWon䜒䛣䛾༢఩䛷㓄ᕸ 
㻝㻜
Module 
ᇶᮏⓗ䛻Project䛾Target䛜Moduleྡ䛻䛺䜛 
㻝㻝
Module䛸ྡ๓✵㛫 
petamp 
Module䛾㻌MyClass 
䛸䛔䛖Class䛿 
petamp.MyClass 
䛜䝣䝹䝛䞊䝮䛻䛺䜛䚹 
Module㛫䛷ྡ๓䛜㔜」䛧䛯ሙྜ䛿⛥䛻䛣䛾 
䜘䛖䛺ᣦᐃ䛜ᚲせ䛻䛺䜛䚹 
㻝㻞
Accessಟ㣭Ꮚ 
• public 
protected 
䛸䛛䛿↓䛔 
– ௚䛾Module䛛䜙䜰䜽䝉䝇ྍ⬟ 
• Internal 
(┬␎᫬䛿䛣䜜䠅 
– ྠ୍Moduleෆ䛺䜙䜰䜽䝉䝇ྍ⬟ 
– ௚䛾Module䛛䜙䛿䜰䜽䝉䝇䛷䛝䛺...
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
౛䛘䜀䚸String䛺䛹䛾୍䛴䛾ᆺ䛻ᑐ䛧䛶䚸䠏䛴䛾ᆺ䛜䛒䜛 
᭱ึ䛿ᑡ䛧 
ᝎ䜐䜣䛰䜘䛽 
㻝㻠 
String 
String? 
String! 
䛣䛾㻌䛂ᆺ䟿䛃㻌䛸䛛䛂ᆺ䠛䛃㻌䛿 
䛒䜛ព࿡Swi$䛾᭱኱䛾...
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
㏻ᖖ䛾ᆺ䛾ኚᩘ䛻nil䛿௦ධ䛷䛝䛺䛔 
? 
䛛㻌! 
䜢௜䛡䜛䛸㻌nil 
䜢௦ධ䛷䛝䜛 
䝁䞁䝟䜲䝹䜶䝷䞊 
㻝㻡
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
㛵ᩘ䛺䛹䛾௬ᘬᩘ䛷䜒ྠ䛨 
䛣䜜䜒 
䝁䞁䝟䜲䝹䜶䝷䞊 
㻝㻢
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
䛂ᆺ!䛃䛿䚸 
┤᥋䛂ᆺ䛃䜈䜰䜽䝉䝇䛷䛝䜛 
ኚᩘ䛾ෆᐜ䛜nil䛺䜙ᐇ⾜᫬䜶䝷䞊䛻䛺䜛 
Nil䛰䛸䜃䛳䛟䜚䟿 
䛧䛶ⴠ䛱䜛 
㻝㻣
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
䛂ᆺ?䛃䛿䚸 
䛂ኚᩘ?䛃䛛䛂ኚᩘ!䛃䜢౑䜟䛺䛔䛸䛂ᆺ䛃䜈䜰䜽䝉䝇䛷䛝䛺䛔 
᭱ᚋ䛾䛿 
䝁䞁䝟䜲䝹䜶䝷䞊 
㻝㻤
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
䛂ኚᩘ?䛃䛿䚸ኚᩘ䛾ෆᐜ䛜nil䛺䜙⤖ᯝ䛜nil䛻䛺䜛 
䛂ኚᩘ!䛃䛿䚸ኚᩘ䛾ෆᐜ䛜nil䛺䜙ᐇ⾜᫬䜶䝷䞊䛻䛺䜛 
?䛾ືస䛿 
ᚑ᮶䛾ObjC䛸ྠ䛨䛰䛽 
㻝㻥
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
㢖ฟ䛺グἲ䛰䜘 
ᆺ? 
䜔㻌ᆺ! 
䛾᫬䛾 
nil 
䝏䜵䝑䜽䛾ᐃ␒ 
‘if 
let’ 
name 
!= 
nil 
䛾䛸䛝 
sureName 
䛻 
name! 
䛜௦ධ䛥䜜䜛 
㻞㻜
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 
var 
name: 
String 
䜢౛䛻䛩䜛䛸 
ᆺ nil䛾௦ධ 
ෆᐜ䜈䛾䜰䜽䝉䝇 
ෆᐜ䛜nil 
䛰䛳䛯ሙྜ 
String 䛷䛝䛺䛔 name.isEmpty 䛒䜚ᚓ䛺䛔 
String? 䛷䛝䜛...
䛂ᆺ䟿䛃䛾౑䛔䛹䛣䜝䛿䠛 
䛂ᆺ䟿䛃䛿nil䛾䝏䜵䝑䜽䜢䛧䛺䛔༴㝤䛺ᆺ 
䛰䛡䛹䚸 
䛂䜋䜌㛫㐪䛔䛺䛟nil䛨䜓䛺䛔䛃 
䛂䜒䛧nil䛺䜙ⴠ䛱䛯䜋䛖䛜䝬䝅䛰䛧䛩䛠䜟䛛䜛䛃 
䜘䛖䛺ሙྜ䛿౑䛖䛸౽฼䛷䛩 
㻞㻞
Swi$䛾nil䝏䜵䝑䜽䛿⤖ᵓ䛧䛳䛛䜚䛧䛶䛔䜛 
Class䛿䝯䞁䝞ኚᩘ䛜 
init() 
䛷ึᮇ໬䛥䜜䛶䛺䛔䛸 
䝁䞁䝟䜲䝹䜶䝷䞊䛻䛺䜛 
䛣䜜䛿NG 
䛣䜜䛺䜙OK 
㻞㻟
䛂ᆺ䟿䛃䛾౑䛔䛹䛣䜝: 
౛䛘䜀 
ViewController 
䛺䛹䛿init()䛷䛿䛺䛟䚸 
኱᢬㻌viewDidLoad 
䛺䛹䛷ึᮇ໬䛩䜛䛾䛷 
䝯䞁䝞ኚᩘ䛿㻌ᆺ? 
䛛㻌ᆺ! 
䛻䛩䜛ᚲせ䛜䛒䜛䚹 
䛭䛾୰䛷 
䛂እ㒊䛛䜙ᚲ䛪䝉䝑䝖...
nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ䞉䜎䛸䜑 
• 䝯䞁䝞ኚᩘ䜔API䛜nil䜢㏉䛩䛛䛜᫂♧䛥䜜䜛 
– 䜘䜚䛂ពᅗ䜢䛣䜑䛯䛃䝥䝻䜾䝷䝮䛻䛺䜛 
• nil䛻ᑐ䛩䜛ㄆ㆑㐪䛔䛜ῶ䜚䚸Ᏻ඲䛺䝁䞊䝗䛻䛺䜛 
NilᏳ඲ 
㻞㻡
ObjecWve-­‐C 
䛸䛾㐃ᦠ䠖 
ObjC 
䜢 
Swi$䛛䜙ཧ↷ 
projectྡ-­‐Bridging-­‐Header.h 
䛸䛔䛖䝣䜯䜲䝹䜢స䛳䛶䛭䛣䛻 
importᩥ䜢᭩䛟 
petamp-­‐Bridging-­‐He...
ObjecWve-­‐C 
䛸䛾㐃ᦠ䠖 
Swi$䜢ObjC䛛䜙ཧ↷ 
1. Swi$䛾Class䜢public䛻䛧䛯䜚䚸@objc䜢௜䛡䜛 
2. ObjC䛷䛿㻌projectྡ-­‐Swi$.h 
䜢 
import䛩䜛 
petamp䝥䝻...
@objc 
䛳䛶䛺䜣䛰䠛 
䜲䝬䜲䝏䜘䛟⌮ゎ䛧䛶䛺䛔䞉䞉䞉 
• ObjecWve-­‐Cഃ䛻export䛩䜛䛸䛝䛻௜䛡䜛 
• Protocol䜢weak䛷ಖᣢ䛩䜛䛸䛝䛻௜䛡䜛 
䛸䛛䛷౑䛖䜏䛯䛔䚹 
㻞㻤
Swi$䛾౽฼䛺䛸䛣䜝 
㻞㻥
Header䝣䜯䜲䝹䜢᭩䛛䛺䛟䛶Ⰻ䛔䟿 
• ᆅ࿡䛻䛛䛺䜚Ꮀ䛧䛔 
• Property䛸䛛䛾ᐉゝ䜒≉䛻᭩䛛䛺䛟䛶Ⰻ䛔 
• ඲యⓗ䛻ᩥᏐᩘ䛜䛛䛺䜚ῶ䛳䛶䚸䛭䜜䛰䛡䛷ᴦ 
.h䛸.m䜢 
⾜䛳䛯䜚᮶䛯䜚 
䛧䛺䛟䛶䜘䛟䛺䛳䛯 
㻟㻜
ጁ䛺Prefix䜢Classྡ䛺䛹䛻௜䛡䛺䛟䛶Ⰻ䛔 
Module䛾ྡ๓✵㛫䛜䛒䜛䛾䛷䛂YMY䛃䛾䜘䛖䛺 
Prefix䜢ᐃᩘ䜔Classྡ䛻䛴䛡䜛ᚲせ䛜䛺䛟䛺䛳䛯䚹 
䝃䞊䝗䝟䞊䝔䜱䛾䝷䜲䝤䝷䝸ෆ䛷 
Prefix䜢௜䛡ᛀ䜜䛶䛔䛶⾪✺䛩䜛 
...
䜟䜚䛸ᆺᏳ඲䚸nil䜒Ᏻ඲ 
• idᆺ䛰䛸䛺䜣䛷䜒௦ධ䛷䛝䛶䛧䜎䛳䛶䛔䛯 
• Generics䜔OpWonal䛾௙ᵝ䛾䛚䛛䛢䛷䚸 
䛰䛔䜆䝁䞁䝟䜲䝹᫬䛾䝏䜵䝑䜽䛜䛥䜜䜛䜘䛖䛻䛺䛳䛯 
• ᆺ᥎ㄽ䛾䛚䛛䛢䛷グ㏙㔞䛿䛭䜜䜋䛹ቑ䛘䛺䛔 
ᐇ⾜䛩䜛...
௚䛻䜒䛔䜝䛔䜝Ẽ䛜฼䛔䛶䛔䜛 
• Closure䛜᭩䛝䜔䛩䛔 
• ᙉຊ䛺Switch 
Case 
• enum 
䛜䛛䛺䜚㧗ᶵ⬟ 
• ྍኚ㛗ᘬᩘ䛾㛵ᩘ䛜ᐃ⩏䛧䜔䛩䛔 
• ᘬᩘ䛻default್䜢ᐃ⩏䛷䛝䜛 
• Class 
prop...
Swi$䛾Ẽ䜢䛴䛡䜛Ⅼ 
㻟㻠
ObjCഃ䛾 
weakኚᩘ䛻ὀព 
↑䛣䛖䛔䛖 
property䛻 
Swi$ഃ䛾Object䜢 
௦ධ䠄⤖ᯝⓗ䛻䠅䛩䜛㝿䛻 
NSObject䜢⥅ᢎ䛧䛶䛺䛔䛸௦ධ䛥䜜䛺䛔 
h6p://qiita.com/mokemokechicken/...
@selector 
䛷࿧䜆Object䛻ὀព 
UIBu6on#addTarget 
NSNoWficaWonCenter#addObserver 
䛺䛹䛷㻌@selector䜢౑䛖ᣦᐃ䜢䛩䜛ሙྜ䚸 
䛭䛾ᑐ㇟䛸䛺䜛Object䛿 
NSOb...
@selector 
䛷࿧䜆Object䛻ὀព 
㻟㻣 
䛣䜣䛺䝁䞊䝗䛰䛸䜽䝷䝑䝅䝳䛩䜛 
Hoge 
䛣䛣䛷䜽䝷䝑䝅䝳䟿 
䛜 
NSObject䜢⥅ᢎ䛧䛯䜚䚸 
@objc 
ಟ㣭䛥䜜䛶䛔䜜䜀኱୔ኵ 
h6p://qiita.com/mok...
protected䛾䜰䜽䝉䝇ಟ㣭Ꮚ䛜䛺䛔 
• Java䛸䛛C#䛾ឤぬ䛷䜽䝷䝇タィ䛩䜛䛸ᅔ䜛᫬䜒 
• 䛣䛾㎶䜚䛿ObjecWve−C䛾᫬䛸ኚ䜟䛳䛶䛺䛔 
䜐䛪䛔 
㻟㻤
༢య䝔䝇䝖䜢᭩䛟᫬䛻ᝎ䜐 
● 
㏻ᖖ䛿䝔䝇䝖䝥䝻䝆䜵䜽䝖䛿ูModule䛻䛺䜛 
● 
ู䝰䝆䝳䞊䝹䛛䜙ཧ↷䛩䜛䛻䛿㻌public 
䛷䛒䜛ᚲせ䛜䛒䜛 
ู䚻 
㻟㻥
༢య䝔䝇䝖䜢᭩䛟᫬䛻ᝎ䜐 
[㑅ᢥ] 
䠍䠅㻌䝔䝇䝖ᑐ㇟䛾䝁䞊䝗䜢඲䛶public䛻䛩䜛 
䠎䠅㻌䝸䝸䞊䝇⏝䛾䝁䞊䝗䜢䝔䝇䝖䝥䝻䝆䜵䜽䝖䛻ྵ䜑䜛 
䛣䜣䛺ឤ䛨 
䕪 
䠏䠅㻌䝔䝇䝖䜢᭩䛛䛺䛔 
௒䛿䠎䛷 
䜔䛳䛶䜎䛩 
㻠㻜
䛥䛔䛤䛻 
• Swi$䛿༑ศᐇ⏝ⓗ䛷㛤Ⓨຠ⋡䜒ୖ䛜䜚䛭䛖 
• iOS䜶䞁䝆䝙䜰䛺䜙ぬ䛘䜛ᚲせ䛜䛒䜛䛰䜝䛖 
• 䛷䜒 
ObjecWve-­‐C 
⤒㦂⪅䛺䜙㞴䛧䛟↓䛔䛛䜙኱୔ኵ䟿 
Swi$ 
䛾ព࿡䛿 
䛂㏿䛔䚸㎿㏿䛺䛃 
㻠㻝
Próxima SlideShare
Cargando en…5
×

SwiftでのiOSアプリ開発

13.471 visualizaciones

Publicado el

SwiftでiOSアプリ開発を行ったときの体験やポイントを共有します。

Publicado en: Software
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website! https://vk.cc/818RFv
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí

SwiftでのiOSアプリ開発

  1. 1. Swi$䛷䛾iOS䜰䝥䝸㛤Ⓨ 2014ᖺ9᭶ 䜖䜑䜏㻌᳃ୗ㻌೺ 㻝
  2. 2. ⮬ᕫ⤂௓ • mokemokechicken @{Twi6er, Facebook, Github, Qiita} • ᰴᘧ఍♫䜖䜑䜏㻌2014ᖺᗘCTO ௵ᮇ䛿1ᖺ䛺䛾䛷䛩 • タィ/䜲䞁䝣䝷/䝃䞊䝞䝃䜲䝗/iOS 䛜୺ • 䛣䜒䜣䛱䜓䜣ዲ䛝䛺஧ඣ䛾䝟䝟 㻞
  3. 3. ♫ෆPJ䛷ᬤ䛺䛸䛝䛻 䛣䜣䛺䜰䝥䝸䜢స䛳䛶䜎䛧䛯 (䜎䛰⤊䜟䛳䛶䛺䛔…) • Ꮚ౪ྥ䛡䜰䝥䝸 • 䜋䜌Swi$䛷 • Core Data䜒฼⏝ 䛣䛾㛤Ⓨ䜢㏻䛧䛶ᚓ䛯䛣䛸䜢௒᪥䛿䛤⤂௓䛧䜎䛩 㻟
  4. 4. Swi$䛾㉸ᇶᮏ 㻠
  5. 5. Swi$䛿䝰䝎䞁䛺ゝㄒ ୙ኚ䛺ኚᩘ䜔Object䜢స䜜䜛 ᆺ᥎ㄽ䛻䜘䜛䝇䝖䝺䝇䛾ᑡ䛺䛔䝁䞊䝕䜱䞁䜾 㛵ᩘᆺゝㄒ䛾≉ᚩ䜢ᣢ䛴 Generics䛒䜚䜎䛩 CocoaPods 䜒౑䛘䜛䜘 ⤮ᩥᏐ䜒ኚᩘ䞉㛵ᩘྡ䛻౑䛘䜎䛩(^^; 㻡
  6. 6. ୙ኚ䛺ኚᩘ䜔Object䜢స䜜䜛 var 䛿෌௦ධྍ⬟䛺ኚᩘ let 䛿෌௦ධ୙ྍ⬟䛺ᐃᩘ 䜶䝷䞊䛻䛺䜛 㻢
  7. 7. ᆺ᥎ㄽ䛻䜘䜛䝇䝖䝺䝇䛾ᑡ䛺䛔䝁䞊䝕䜱䞁䜾 ᆺ䛜ྑ㎶䛺䛹䛛䜙᥎ 䛷䛝䜛ሙྜ䛿┬␎ྍ⬟ ┬␎OK ↓㥏䛰䛧䛽 㻣
  8. 8. 㛵ᩘᆺゝㄒ䛾≉ᚩ䜢ᣢ䛴 㛵ᩘ䜢ᘬᩘ䛻ྲྀ䜜䜛 䠄䝣䜯䞊䝇䝖䜽䝷䝇㛵ᩘ䛷䛒䜛䠅 䕔 䛱䜗䛳䛸౽฼ ᭱ᚋ䛾ᘬᩘ䛜㛵ᩘ䛺䜙 䜹䝑䝁䜢㛢䛨䛶䛛䜙Closure䜢᭩䛟䛣䛸䜒䛷䛝䜛 䜒䛿䜔Blocks䛿 ྂ௦ㄒ㨱⾡ 㻤
  9. 9. ኱஦䛺ゝㄒ௙ᵝ 䛔䛟䛴䛛 Pickup䛩䜛䜘 㻥
  10. 10. Module • 䝁䞊䝗䜢㓄ᕸ䛩䜛༢఩ • ‘import’ 䛷௚䛾Module䜢ཧ↷䛷䛝䜛 • Framework䜔ApplicaWon䜒䛣䛾༢఩䛷㓄ᕸ 㻝㻜
  11. 11. Module ᇶᮏⓗ䛻Project䛾Target䛜Moduleྡ䛻䛺䜛 㻝㻝
  12. 12. Module䛸ྡ๓✵㛫 petamp Module䛾㻌MyClass 䛸䛔䛖Class䛿 petamp.MyClass 䛜䝣䝹䝛䞊䝮䛻䛺䜛䚹 Module㛫䛷ྡ๓䛜㔜」䛧䛯ሙྜ䛿⛥䛻䛣䛾 䜘䛖䛺ᣦᐃ䛜ᚲせ䛻䛺䜛䚹 㻝㻞
  13. 13. Accessಟ㣭Ꮚ • public protected 䛸䛛䛿↓䛔 – ௚䛾Module䛛䜙䜰䜽䝉䝇ྍ⬟ • Internal (┬␎᫬䛿䛣䜜䠅 – ྠ୍Moduleෆ䛺䜙䜰䜽䝉䝇ྍ⬟ – ௚䛾Module䛛䜙䛿䜰䜽䝉䝇䛷䛝䛺䛔 • private – ྠ୍䝣䜯䜲䝹ෆ䛺䜙䜰䜽䝉䝇ྍ⬟ – ௚䛾䝣䜯䜲䝹䛛䜙䛿䜰䜽䝉䝇䛷䛝䛺䛔 㻝㻟
  14. 14. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ ౛䛘䜀䚸String䛺䛹䛾୍䛴䛾ᆺ䛻ᑐ䛧䛶䚸䠏䛴䛾ᆺ䛜䛒䜛 ᭱ึ䛿ᑡ䛧 ᝎ䜐䜣䛰䜘䛽 㻝㻠 String String? String! 䛣䛾㻌䛂ᆺ䟿䛃㻌䛸䛛䛂ᆺ䠛䛃㻌䛿 䛒䜛ព࿡Swi$䛾᭱኱䛾≉ᚩ
  15. 15. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ ㏻ᖖ䛾ᆺ䛾ኚᩘ䛻nil䛿௦ධ䛷䛝䛺䛔 ? 䛛㻌! 䜢௜䛡䜛䛸㻌nil 䜢௦ධ䛷䛝䜛 䝁䞁䝟䜲䝹䜶䝷䞊 㻝㻡
  16. 16. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 㛵ᩘ䛺䛹䛾௬ᘬᩘ䛷䜒ྠ䛨 䛣䜜䜒 䝁䞁䝟䜲䝹䜶䝷䞊 㻝㻢
  17. 17. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 䛂ᆺ!䛃䛿䚸 ┤᥋䛂ᆺ䛃䜈䜰䜽䝉䝇䛷䛝䜛 ኚᩘ䛾ෆᐜ䛜nil䛺䜙ᐇ⾜᫬䜶䝷䞊䛻䛺䜛 Nil䛰䛸䜃䛳䛟䜚䟿 䛧䛶ⴠ䛱䜛 㻝㻣
  18. 18. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 䛂ᆺ?䛃䛿䚸 䛂ኚᩘ?䛃䛛䛂ኚᩘ!䛃䜢౑䜟䛺䛔䛸䛂ᆺ䛃䜈䜰䜽䝉䝇䛷䛝䛺䛔 ᭱ᚋ䛾䛿 䝁䞁䝟䜲䝹䜶䝷䞊 㻝㻤
  19. 19. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 䛂ኚᩘ?䛃䛿䚸ኚᩘ䛾ෆᐜ䛜nil䛺䜙⤖ᯝ䛜nil䛻䛺䜛 䛂ኚᩘ!䛃䛿䚸ኚᩘ䛾ෆᐜ䛜nil䛺䜙ᐇ⾜᫬䜶䝷䞊䛻䛺䜛 ?䛾ືస䛿 ᚑ᮶䛾ObjC䛸ྠ䛨䛰䛽 㻝㻥
  20. 20. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ 㢖ฟ䛺グἲ䛰䜘 ᆺ? 䜔㻌ᆺ! 䛾᫬䛾 nil 䝏䜵䝑䜽䛾ᐃ␒ ‘if let’ name != nil 䛾䛸䛝 sureName 䛻 name! 䛜௦ධ䛥䜜䜛 㻞㻜
  21. 21. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ var name: String 䜢౛䛻䛩䜛䛸 ᆺ nil䛾௦ධ ෆᐜ䜈䛾䜰䜽䝉䝇 ෆᐜ䛜nil 䛰䛳䛯ሙྜ String 䛷䛝䛺䛔 name.isEmpty 䛒䜚ᚓ䛺䛔 String? 䛷䛝䜛 name?.isEmpty nil䛻䛺䜛 name!.isEmpty ᐇ⾜᫬䜶䝷䞊 String! 䛷䛝䜛 name.isEmpty ᐇ⾜᫬䜶䝷䞊 䟿䛾᫬䛰䛡 䜶䝷䞊䛜䛒䜚ᚓ䜛 㻞㻝
  22. 22. 䛂ᆺ䟿䛃䛾౑䛔䛹䛣䜝䛿䠛 䛂ᆺ䟿䛃䛿nil䛾䝏䜵䝑䜽䜢䛧䛺䛔༴㝤䛺ᆺ 䛰䛡䛹䚸 䛂䜋䜌㛫㐪䛔䛺䛟nil䛨䜓䛺䛔䛃 䛂䜒䛧nil䛺䜙ⴠ䛱䛯䜋䛖䛜䝬䝅䛰䛧䛩䛠䜟䛛䜛䛃 䜘䛖䛺ሙྜ䛿౑䛖䛸౽฼䛷䛩 㻞㻞
  23. 23. Swi$䛾nil䝏䜵䝑䜽䛿⤖ᵓ䛧䛳䛛䜚䛧䛶䛔䜛 Class䛿䝯䞁䝞ኚᩘ䛜 init() 䛷ึᮇ໬䛥䜜䛶䛺䛔䛸 䝁䞁䝟䜲䝹䜶䝷䞊䛻䛺䜛 䛣䜜䛿NG 䛣䜜䛺䜙OK 㻞㻟
  24. 24. 䛂ᆺ䟿䛃䛾౑䛔䛹䛣䜝: ౛䛘䜀 ViewController 䛺䛹䛿init()䛷䛿䛺䛟䚸 ኱᢬㻌viewDidLoad 䛺䛹䛷ึᮇ໬䛩䜛䛾䛷 䝯䞁䝞ኚᩘ䛿㻌ᆺ? 䛛㻌ᆺ! 䛻䛩䜛ᚲせ䛜䛒䜛䚹 䛭䛾୰䛷 䛂እ㒊䛛䜙ᚲ䛪䝉䝑䝖䛥䜜䜛ኚᩘ䛃 䛂IBOutlet䛾䜘䛖䛺ኚᩘ䛃 䛿䚸ᆺ!䛺䛹䛷䜒኱᢬OK䛸ゝ䛘䜛䚹 㻞㻠
  25. 25. nil䛻㛵䛩䜛ぶษ䛺ゝㄒ௙ᵝ䞉䜎䛸䜑 • 䝯䞁䝞ኚᩘ䜔API䛜nil䜢㏉䛩䛛䛜᫂♧䛥䜜䜛 – 䜘䜚䛂ពᅗ䜢䛣䜑䛯䛃䝥䝻䜾䝷䝮䛻䛺䜛 • nil䛻ᑐ䛩䜛ㄆ㆑㐪䛔䛜ῶ䜚䚸Ᏻ඲䛺䝁䞊䝗䛻䛺䜛 NilᏳ඲ 㻞㻡
  26. 26. ObjecWve-­‐C 䛸䛾㐃ᦠ䠖 ObjC 䜢 Swi$䛛䜙ཧ↷ projectྡ-­‐Bridging-­‐Header.h 䛸䛔䛖䝣䜯䜲䝹䜢స䛳䛶䛭䛣䛻 importᩥ䜢᭩䛟 petamp-­‐Bridging-­‐Header.h 㻞㻢
  27. 27. ObjecWve-­‐C 䛸䛾㐃ᦠ䠖 Swi$䜢ObjC䛛䜙ཧ↷ 1. Swi$䛾Class䜢public䛻䛧䛯䜚䚸@objc䜢௜䛡䜛 2. ObjC䛷䛿㻌projectྡ-­‐Swi$.h 䜢 import䛩䜛 petamp䝥䝻䝆䜵䜽䝖䛾ሙྜ 㻞㻣
  28. 28. @objc 䛳䛶䛺䜣䛰䠛 䜲䝬䜲䝏䜘䛟⌮ゎ䛧䛶䛺䛔䞉䞉䞉 • ObjecWve-­‐Cഃ䛻export䛩䜛䛸䛝䛻௜䛡䜛 • Protocol䜢weak䛷ಖᣢ䛩䜛䛸䛝䛻௜䛡䜛 䛸䛛䛷౑䛖䜏䛯䛔䚹 㻞㻤
  29. 29. Swi$䛾౽฼䛺䛸䛣䜝 㻞㻥
  30. 30. Header䝣䜯䜲䝹䜢᭩䛛䛺䛟䛶Ⰻ䛔䟿 • ᆅ࿡䛻䛛䛺䜚Ꮀ䛧䛔 • Property䛸䛛䛾ᐉゝ䜒≉䛻᭩䛛䛺䛟䛶Ⰻ䛔 • ඲యⓗ䛻ᩥᏐᩘ䛜䛛䛺䜚ῶ䛳䛶䚸䛭䜜䛰䛡䛷ᴦ .h䛸.m䜢 ⾜䛳䛯䜚᮶䛯䜚 䛧䛺䛟䛶䜘䛟䛺䛳䛯 㻟㻜
  31. 31. ጁ䛺Prefix䜢Classྡ䛺䛹䛻௜䛡䛺䛟䛶Ⰻ䛔 Module䛾ྡ๓✵㛫䛜䛒䜛䛾䛷䛂YMY䛃䛾䜘䛖䛺 Prefix䜢ᐃᩘ䜔Classྡ䛻䛴䛡䜛ᚲせ䛜䛺䛟䛺䛳䛯䚹 䝃䞊䝗䝟䞊䝔䜱䛾䝷䜲䝤䝷䝸ෆ䛷 Prefix䜢௜䛡ᛀ䜜䛶䛔䛶⾪✺䛩䜛 䛸䛔䛖஦௳䜒䛺䛟䛺䜛䚹 ୙ᖾ䛺஦௳䛰䛳䛯 㻟㻝
  32. 32. 䜟䜚䛸ᆺᏳ඲䚸nil䜒Ᏻ඲ • idᆺ䛰䛸䛺䜣䛷䜒௦ධ䛷䛝䛶䛧䜎䛳䛶䛔䛯 • Generics䜔OpWonal䛾௙ᵝ䛾䛚䛛䛢䛷䚸 䛰䛔䜆䝁䞁䝟䜲䝹᫬䛾䝏䜵䝑䜽䛜䛥䜜䜛䜘䛖䛻䛺䛳䛯 • ᆺ᥎ㄽ䛾䛚䛛䛢䛷グ㏙㔞䛿䛭䜜䜋䛹ቑ䛘䛺䛔 ᐇ⾜䛩䜛๓䛻 ၥ㢟ᢕᥱ 㻟㻞
  33. 33. ௚䛻䜒䛔䜝䛔䜝Ẽ䛜฼䛔䛶䛔䜛 • Closure䛜᭩䛝䜔䛩䛔 • ᙉຊ䛺Switch Case • enum 䛜䛛䛺䜚㧗ᶵ⬟ • ྍኚ㛗ᘬᩘ䛾㛵ᩘ䛜ᐃ⩏䛧䜔䛩䛔 • ᘬᩘ䛻default್䜢ᐃ⩏䛷䛝䜛 • Class property 䛾 get, set, willSet, didSet • extension 䛻䜘䜛ᣑᙇ䚸Int 䛺䛹䜒ᣑᙇ䛷䛝䜛 㻟㻟
  34. 34. Swi$䛾Ẽ䜢䛴䛡䜛Ⅼ 㻟㻠
  35. 35. ObjCഃ䛾 weakኚᩘ䛻ὀព ↑䛣䛖䛔䛖 property䛻 Swi$ഃ䛾Object䜢 ௦ධ䠄⤖ᯝⓗ䛻䠅䛩䜛㝿䛻 NSObject䜢⥅ᢎ䛧䛶䛺䛔䛸௦ධ䛥䜜䛺䛔 h6p://qiita.com/mokemokechicken/items/c0386acqb37429f9c16 䝎䝯 䝎䝯 OK 䛂䝎䝯䛃䛺䜔䛴䛿䛩䛠䛻nil䛻䛺䜚䜎䛩 㻟㻡
  36. 36. @selector 䛷࿧䜆Object䛻ὀព UIBu6on#addTarget NSNoWficaWonCenter#addObserver 䛺䛹䛷㻌@selector䜢౑䛖ᣦᐃ䜢䛩䜛ሙྜ䚸 䛭䛾ᑐ㇟䛸䛺䜛Object䛿 NSObject䜢⥅ᢎ䛧䛯䜚䚸@objc 䛾䜘䛖䛺ಟ㣭䛜ᚲせ䚹 䜒䛧䛭䜜䜙䛜䛺䛡䜜䜀Crash䛩䜛䚹 㻟㻢 h6p://qiita.com/mokemokechicken/items/9d7b941a45a5534411c9
  37. 37. @selector 䛷࿧䜆Object䛻ὀព 㻟㻣 䛣䜣䛺䝁䞊䝗䛰䛸䜽䝷䝑䝅䝳䛩䜛 Hoge 䛣䛣䛷䜽䝷䝑䝅䝳䟿 䛜 NSObject䜢⥅ᢎ䛧䛯䜚䚸 @objc ಟ㣭䛥䜜䛶䛔䜜䜀኱୔ኵ h6p://qiita.com/mokemokechicken/items/9d7b941a45a5534411c9
  38. 38. protected䛾䜰䜽䝉䝇ಟ㣭Ꮚ䛜䛺䛔 • Java䛸䛛C#䛾ឤぬ䛷䜽䝷䝇タィ䛩䜛䛸ᅔ䜛᫬䜒 • 䛣䛾㎶䜚䛿ObjecWve−C䛾᫬䛸ኚ䜟䛳䛶䛺䛔 䜐䛪䛔 㻟㻤
  39. 39. ༢య䝔䝇䝖䜢᭩䛟᫬䛻ᝎ䜐 ● ㏻ᖖ䛿䝔䝇䝖䝥䝻䝆䜵䜽䝖䛿ูModule䛻䛺䜛 ● ู䝰䝆䝳䞊䝹䛛䜙ཧ↷䛩䜛䛻䛿㻌public 䛷䛒䜛ᚲせ䛜䛒䜛 ู䚻 㻟㻥
  40. 40. ༢య䝔䝇䝖䜢᭩䛟᫬䛻ᝎ䜐 [㑅ᢥ] 䠍䠅㻌䝔䝇䝖ᑐ㇟䛾䝁䞊䝗䜢඲䛶public䛻䛩䜛 䠎䠅㻌䝸䝸䞊䝇⏝䛾䝁䞊䝗䜢䝔䝇䝖䝥䝻䝆䜵䜽䝖䛻ྵ䜑䜛 䛣䜣䛺ឤ䛨 䕪 䠏䠅㻌䝔䝇䝖䜢᭩䛛䛺䛔 ௒䛿䠎䛷 䜔䛳䛶䜎䛩 㻠㻜
  41. 41. 䛥䛔䛤䛻 • Swi$䛿༑ศᐇ⏝ⓗ䛷㛤Ⓨຠ⋡䜒ୖ䛜䜚䛭䛖 • iOS䜶䞁䝆䝙䜰䛺䜙ぬ䛘䜛ᚲせ䛜䛒䜛䛰䜝䛖 • 䛷䜒 ObjecWve-­‐C ⤒㦂⪅䛺䜙㞴䛧䛟↓䛔䛛䜙኱୔ኵ䟿 Swi$ 䛾ព࿡䛿 䛂㏿䛔䚸㎿㏿䛺䛃 㻠㻝

×