Core Data ( ²Åé ¦r) |
§@ªÌ¡GFlorian Kugler¡]¦òùµÜ®¦¡P®w®æ°Ç¡^,Daniel Eggert¡]¤¦¥§º¸¡P®J®æ¯S¡^ | Ãþ§O¡G1. -> µ{¦¡³]p -> ºî¦X |
ĶªÌ¡G |
¥Xª©ªÀ¡G¹q¤l¤u·~¥Xª©ªÀ | 3dWoo®Ñ¸¹¡G 45135 ¸ß°Ý®ÑÄy½Ð»¡¥X¦¹®Ñ¸¹¡I¡i¦³®w¦s¡j NT°â»ù¡G 345 ¤¸ |
¥Xª©¤é¡G9/1/2016 |
¶¼Æ¡G252 |
¥úºÐ¼Æ¡G0 |
|
¯¸ªø±ÀÂË¡G |
¦L¨ê¡G¶Â¥Õ¦L¨ê | »y¨t¡G ( ²Åé ª© ) |
|
¥[¤JÁʪ«¨® ¢x¥[¨ì§Úªº³Ì·R (½Ð¥ýµn¤J·|û) |
ISBN¡G9787121294594 |
§@ªÌ§Ç¡@|¡@ĶªÌ§Ç¡@|¡@«e¨¥¡@|¡@¤º®e²¤¶¡@|¡@¥Ø¿ý¡@|¡@§Ç |
(²Åé®Ñ¤W©Òz¤§¤U¸ü³sµ²¯Ó®É¶O¥\, ®¤¤£¾A¥Î¦b¥xÆW, YŪªÌ»Ýn½Ð¦Û¦æ¹Á¸Õ, ®¤¤£«OÃÒ) |
§@ªÌ§Ç¡G |
ĶªÌ§Ç¡G |
«e¨¥¡GĶ§Ç
¦b 20 ¥@¬ö 60 ¦~¥N¡A¾É¯è¦¡¼Æ¾Ú®wªº·§©ÀÀHµÛºÏ½Lª½±µ¦s¨ú¦Óµo®i°_¨Ó¡F±q 70 ¦~¥N¶}©l¡A Ãö¨t«¬¼Æ¾Ú®wµn¤W¾ú¥v»R»O¡A¥¦ªº·§©À¤@ª½©µÄò¦Ü¤µ¡C§Ú̵Lªk·Q¶H²{¥Nªºpºâ¾÷µ{§Ç¤¤ Â÷¶}¤F¼Æ¾Ú®w·|¬O«ç¼Ëªº´º¶H¡A¼Æ¾Ú®w§Þ³N¤w¸g¦¨¤F³oÓ¥@¬É¤è¤è±±ªº°ò¥Û¡C ¦b¼Æ¾ÚºÞ²z©M¼Æ¾Ú®w¬ÛÃöªº¤è±¡AAppleµ¹¥Xªº¿ï¾Ü¬OCore Data¡C¥¿¦p¦b²¤¶¤¤©Ò´£¨ìªº¨º ¼Ë¡ACore Data¨ä¹ê¦}¤£¬O¤@ӶDzηN¸q¤Wªº¼Æ¾Ú®w¡A¦Ó¬O¤@®M¹ï¶H¹ÏºÞ²z¨t²Î¡C³o®M¨t²Î Àq»{¨Ï¥ÎSQLite§@¬°©³¼h¦sÀx¡A³q¹L¥Ñ§C¦V°ª¦a±N¬ÛÃöªººÞ²z²Õ¥óºc«Ø¬°¤@Ó´Ì¡A¨Ó´£¨Ñ ½w¦s©M¹ï¶HºÞ²z¾÷¨î¡C³oÅý§Ú̹ï¤_¼Æ¾Ú¹ï¶Hªº¦sÀx©M³X°Ý³£¯à°÷°ª®Ä¦Ó¦³§Ç¦a¶i¦æ¡C±q ³o¤@ÂI¤W¨Ó»¡¡ACore Data»P³æ¯Âªº¼Æ¾Ú®w¬Û¤ñ¡A¹ê¦b¬O±j¤j±o¦h¡C ¦ý¬O¯à¤O¶V¤j¡A³d¥ô¤]¶V¤j¡C¦pªG¨Ï¥Î¤£·í¡A¨º¤\Core Data¤£¦ý¤£¯à¬°§A´£¨Ñ¨}¦nªº¼Æ¾Ú ¦sÀx©M³X°Ýªº©Ê¯à¡A¬Æ¦Ü·|³s³Ì°ò¥»ªº¾Þ§@³£Ãø¥H«OÃÒ¡C¦b³oºØ±¡ªp¤U¡ACore Data±N¤£¦A ¬O§A¶}µoªº§U¤O¡A¤Ï¦Ó·|¦¨¬°´w¨y¡C¤£©¯ªº¬O¡ACore Data¥»¨¾Ç²ß¦±½u¤ñ¸û°~®k¡A¦Ó¯A¤Î ªº·§©À¤S«D±`¦h¡A©Ò¥H¯u¥¿·Qnºë³qCore Data¦}§¹¥þµo´§¥¦ªº®Ä¯à¦}¤£¬O«Ü®e©öªº¨Æ±¡¡C Apple¦biOSªº«Ü¦hì¥ÍÀ³¥Î¤¤¤j¶q¨Ï¥Î¤FCore Data¡A¤ñ¦p·Ó¤ù¡Bµ¼Ö©MiBooksµ¥¡A¦}¥B ¨Æ¹êÃÒ©ú¥¦Ì³£¥X¦â¦a§¹¦¨¤F¥ô°È¡C¦b°ê¥~¡A¤]¦³«Ü¦h¶}µoªÌ¨Ï¥ÎCore Data§@¬°À³¥Îµ{§Ç ªº¼Æ¾Ú¼h©M«ù¤[¤Æªº¿ï¾Ü¡C¬Û¤ñ¨ä¥L²Ä¤T¤èªº¸Ñ¨M¤è®×¡ACore Data¤£»Ýn¤Þ¤JÃB¥~ªº®Ø¬[¡A ¤]¬Û¹ïéw¥i¾a¡C¦ý¬O¦b°ê¤º¡A²{¦b¨Ï¥Î³o¶µ§Þ³Nªº¶}µoªÌ¸û¤Ö¡A¤j®a¹ïCore Dataªº¬ã¨s ¤]´¶¹M¨S¦³°ê¥~²`¤J¡A³o¾ÉP¤F´£¨ìCore Data«Ü¦h¤H·|¤£¦Ûı¦a§Ü©Ú©M¸úÁסC±NCore Data ªº¨Ï¥Î¤èªk©M³Ì¨Î¹ê½î¥H§ó®e©ö²z¸Ñªº¤è¦¡±aµ¹°ê¤º¶}µoªÌ¡A«P¶i¤j®a±µÄ²Core Dataªº¬[ ºc©M«ä·Q¡A³o¥¿¬O§ÚÌ¿ï¾Ü½Ķ¥»®Ñªº¥Øªº¡C ¥»®Ñªºµ²ºc©M¾\Ū¤èªk¦b«e¨¥¤¤·|¦³©Ò»¡©ú¡A³o¨½´N¤£¦AÂØz¤F¡C»Ýn¸É¥Rªº¬O¡A¥»®Ñ¨½ ´£¨Ñ¤F¤j¶qªº¨Ò¤l©M¬ÛÀ³ªº¥N½X¡A¥¦Ì¤j¦h¬O»Ýn¶i¦æÅv¿Åªº¿ï¾Ü¡A¦}¹ïÀ³¤F¤£¦Pªº³õ´º¡C ¥u¦³¦b§A¥R¤À²z¸Ñ³o¨Ç¨Ò¤lªº§t¸q¦Z¡A§A¤~¥i¯à¦b¹ê»Ú¨Ï¥Î®É°µ¥X¥¿½Tªº§PÂ_¡C¥t¥~¡ACore DataªºÆF¬¡©Ê¬O¤@§âÂù¤b¼C¡A·í§A¿ï¾Ü¤F§ó¦hªº¤W¤U¤å¥H¤Î¨ó½Õ¾¹®É¡A¤]·N¨ýµÛ§A¬°¶µ¥Ø ¤Þ¤J¤F§ó¦hªº´_Âø«×¡CºÉ¥i¯à¦b¯à°÷º¡¨¬»Ý¨Dªº«e´£¤U¡A¿ï¾Ü³Ì²³æªºCore Data´Ì³]¸m¡A ¬O°ª®Ä¡B¥¿½T¨Ï¥ÎCore DataªºÃöÁä¡C ¥»®ÑìµÛªº¨â¦ì§@ªÌ¦³µÛ¦h¦~ªºCore Data¨Ï¥Î¸gÅç¡CFlorian Kugler¬Oobjc.ioªºÁp¦X³Ð©l ¤H¡A´¿¸g¬°objc.io¼¶¼g¤F«Ü¦hCore Data¬ÛÃöªº¤å³¹¡A²`¨üŪªÌ³ß·R¡CDaniel Eggert´¿¨Ñ¾ ¤_Apple¡AÀ°§UApple±N·Ó¤ùÀ³¥Î¾E²¾¨ìCore Data®Ø¬[¤º¡C¥L̪º§V¤OÅýCore Data³oÓ¬Ý °_¨Ó¦³¨Ç¡§¥i©È¡¨ªº®Ø¬[Åܱo¥©öªñ¤H¡Aɦ¹§ÚÌ¥i¥H¤@¿sCore Dataªº¨s³º¡C¤£¹L¤£½×¬O ì§@ªÌÁÙ¬OĶªÌ¡A¨ä¹ê©M¦U¦ìŪªÌ¤@¼Ë¡A³£¥u¤£¹L¬O´¶³q¶}µoªÌ¤¤ªº¤@û¡A©Ò¥H¥»®Ñ¥X²{ ÂÕº|¥i¯à¦b©ÒÃø§K¡C¦pªG§A¦b¾\Ū®Éµo²{¤F°ÝÃD¡A¥i¥H³q¹L¥Xª©ªÀÁp¨t§ÚÌ¡A§Ú̱N¤Î®É ¬ã¨s¦}¥[¥H§ï¶i¡C ³Ì¦Z¡A¯¬§A¾\Ū´r§Ö¡C ®}¡@ÀÜ ¿ú¥@®a ¤ý¡@ÄÞ
«e¨¥
Core Data¬OApple¬°iOS¡BOS X¡BwatchOS©MtvOS¦Ó³]pªº¹ï¶H¹ÏºÞ²z(object graph man- agement)©M¼Æ¾Ú«ù¤[¤Æ®Ø¬[¡C¦pªG§AªºApp»Ýn¦sÀxµ²ºc¤Æªº¼Æ¾Ú¡A¨º¤\Core Data¬O¤@Ó Åã¦Ó©ö¨£ªº¤è®×¡G¥¦¬O²{¦¨ªº¡AApple¤´µM¦b¿n·¥¦aºûÅ@¥¦¡A¦Ó¥B¥¦¤w¸g¦s¦b¶W¹L10¦~¤F¡C Core Data¬O¤@Ó¦¨¼ô¡B¸g¹L¹ê½îÀËÅ窺¥N½X®w¡C µM¦Ó Core Data ³Ìªì·|Åý¤H¦³¤@¨Ç§x´b¡G¥¦«D±`ÆF¬¡¡A¦ý¬O API ªº³Ì¨Î¹ê½î«o¦}«DÅã¦Ó©ö ¨£¡C´«¥y¸Ü»¡¡A¥»®Ñªº¥Ø¼Ð¬OÀ°§UŪªÌ§Ö³t¤JªùCore Data¡C§Ú̧Ʊ洣¨Ñµ¹ÅªªÌ¤@¨t¦C¥] ¬A±q²³æ¨ì°ª¯Åªº¨Ï¥Î³õ´º¤¤ªº³Ì¨Î¹ê½î¡A³o¼Ë§A¥i¥H¥R¤À§Q¥ÎCore Dataªº¯à¤O¦Ó¤S¤£·| °g¥¢¦b¤@¨Ç¤£¥²nªº´_Âø©Ê¤¤¡C ¤ñ¦p¡ACore Data¸g±`³Q¸á¯fÃø¥H¦b¦h½uµ{Àô¹Ò¤¤¨Ï¥Î¡C¨ä¹êCore Dataªº¦}µo¼Ò«¬«D±`©ú½T ©M¤@P¡C¦pªG¥¿½T¨Ï¥Î¡A¨º¤\¥¦¥i¥HÀ°§U§AÁקK³\¦h¦}µo½sµ{¤¤¤@¨Ç©T¦³ªº³´¨À¡C¨ä¥Lªº ´_Âø©Ê¦}¤£¬O¥ÑCore Data¤Þ¤Jªº¡A¥¦Ìªº®Ú·½¨ä¹ê¬O¦}µo¥»¨¡C§ÚÌ·|¦b²Ä9³¹¤¤¹ï¨ä¶i ¦æ²`¤J¬ã¨s¡A¥t¥~§ÚÌÁÙ·|¹ê»Úºt¥Ü¤@Ó¦Z»O¦P¨B¤è®×ªº¨Ò¤l¡C °£¦¹¤§¥~¡ACore Data¤]¸g±`³Q¦R¼Ñ©Ê¯àÁV¿|¡C¦pªG§A¹³¨Ï¥ÎÃö¨t«¬¼Æ¾Ú®w¨º¼Ë¨Ó¨Ï¥ÎCore Data¡A¨º¤\§A·|µo²{»Pª½±µ¨Ï¥ÎÃþ¦üSQLite³o¼Ëªº¼Æ¾Ú®w¬Û¤ñ¡ACore Dataªº©Ê¯à¶}¾P·|«Ü °ª¡C¦ý¦pªG§â Core Data ·í¦¨¤@Ó¹ï¶H¹ÏºÞ²z¨t²Î¨Ó¥¿½T¨Ï¥Î¡A¨º¤\±o¯q¤_¤º«Øªº½w¦s©M ¹ï¶HºÞ²z¾÷¨î¡A¥¦¦b«Ü¦h¤è±¹ê»Ú¤W¤Ï¦Ó§ó§Ö¡C¦¹¥~¡A©â¶H¯Å§O§ó°ªªºAPI¥i¥HÅý§A±Mª` ¤_Àu¤ÆApp¨½ÃöÁ䳡¤Àªº©Ê¯à¡A¦Ó¤£¬O±qÀY¶}©l¨Ó¹ê²{¦p¦ó«ù¤[¤Æ¡C¦b¥»®Ñ¤¤¡A§ÚÌ·|¤¶ ²Ð«O«ùCore Data°ª©Ê¯àªº³Ì¨Î¹ê½î¡A¦}¦b±MªùÁ¿©Ê¯à¥H¤Î©Ê¯à¤ÀªRªº³¹¸`¤¤±´°Q¦p¦ó¸Ñ¨M Core Dataªº©Ê¯à°ÝÃD¡C ¥»®Ñ¨Ï¥ÎCore Dataªº¤è¦¡ ¥»®Ñ®i¥Ü¤F¦p¦ó¦b¹ê»Ú¨Ò¤l¤¤¨Ï¥ÎCore Data¡A¦Ó¤£¶È¶È¬O²³æ¦a¹ïAPI¤â¥U¶i¦æ¤@¨ÇÂX®i¡C §Ú̦³·N±Mª`¤_§¹¾ã¨Ò¤lªº³Ì¨Î¹ê½î¡C®Ú¾Ú§Ú̪º¸gÅç¡A¥¿½T¦a²Õ¦X¨Ï¥ÎCore Dataªº¦UÓ ³¡¤À©¹©¹¬O³Ì¤jªº¬D¾Ô¡C ¦¹¥~¡A¥»®ÑÁÙ²`¤J¸ÑÄÀ¤FCore Data¤º³¡ªº¹B§@ì²z¡C¤F¸ÑCore Data³oÓÆF¬¡®Ø¬[¥i¥HÀ° §U§A°µ¥X¥¿½Tªº¨M©w¡A¦P®É¯àÅý§Aªº¥N½X«O«ù²³æ©öÀ´¡C¯S§O¬O·í¹J¨ì¦}µo©M©Ê¯à°ÝÃD®É¡A ³o¤@ÂI¤×¬°«n¡C ¥Ü¨Ò¥N½X §A¥i¥H¦bGitHub¤W§ä¨ì¤@Ó§¹¾ãªº¥Ü¨Òµ{§Çªº·½¥N½X¡C§Ú̦b¥»®Ñ¤¤«Ü¦h¦a¤è³£±N¥Î³o ӥܨҵ{§Ç¨Óºt¥ÜCore Data¦b¸û¤jªº¶µ¥Ø¤¤±Á{ªº¬D¾Ô©M¬ÛÀ³ªº¸Ñ¨M¤è®×¡C ½Ðª`·N¸Ó¥Ü¨Òµ{§Ç¥N½X¦³®É·|©M¥»®Ñ«e±ªº¤@¨Ç³¹¸`¤¤ªº¥Ü¨Òµ{§Ç¦³©Ò¤£¦P¡C¦]¬°¥Ü¨Ò¶µ ¥Ø¬O³Ì²×§ÎºAªº§¹¾ãªº¥N½X¡A¦Ó¥»®Ñ«e±³¹¸`¤¤´yzªº¬O¸Ó¥Ü¨Òµ{§Ç¦´Á¡B²³æ¶¥¬qªº¥N½X¡C µ²ºc ¦b¥»®Ñªº²Ä¤@³¡¤À¡A§ÚÌ·|³Ð«Ø¤@Ó²³æª©¥»ªºÀ³¥Îµ{§Ç¡A¨Óºt¥Ü¦p¦ó¨Ï¥ÎCore Data¥H¤Î Core Dataªº°ò¥»¤u§@ì²z¡C§Y¨Ï¦´Áªº¥Ü¨Ò¹ïŪªÌ¨Ó»¡¥i¯à¬Û·í®e©ö¡A¦ý§Ṳ́´µM«ØijŪ ªÌÂsÄý¥»®Ñªº³o¨Ç³¡¤À¡A¦]¬°¦Z±§ó´_Âøªº¨Ò¤l¬O«Ø¥ß¦b«e±¤¶²Ðªº³Ì¨Î¹ê½î©M§Þ³N°ò¦ ¤§¤Wªº¡C§ÚÌÁÙ·Q§i¶D§Aªº¬O¡A§Y«K¦b²³æªºÀ³¥Î³õ´º¤¤¡ACore Data¤]·|«D±`¦³¥Î¡C ²Ä¤G³¡¤À«hµÛ«²`¤J¤¶²ÐCore Data¦UÓ³¡¤À¬O¦p¦ó¤@°_¨ó§@ªº¡C§ÚÌ·|¥J²Ó±´°Q·í¥H¤£¦P ¤è¦¡³X°Ý¼Æ¾Ú®É·|µo¥Í¤°¤\¡A§Ṳ́]·|¹ï´¡¤J©ÎªÌ¾Þ§@¼Æ¾Ú®Éµo¥Íªº±¡ªp¶i¦æ¬ã¨s¡C³o³¡ ¤À©ÒÂл\ªº¤º®e·|¤ñ¼g¤@Ó²³æªºCore DataÀ³¥Îµ{§Ç©Ò¥²n±o¦h¡A³o¨Ç¤è±ªºª¾ÃѦb³B²z §ó¤j©Î§ó´_Âøªº±¡ªp®É¥i¥H¬£¤W¥Î³õ¡C¦b¦¹°ò¦¤W¡A§Ú̱N¥H©Ê¯à¤è±ªº¦Ò¶q¨Ó¹ï³oÓ³¡ ¤À¶i¦æÁ`µ²¡C ²Ä¤T³¡¤À±q´yz¤@ӥΨӫO«ù¥»¦a¼Æ¾Ú»Pºôµ¸ªA°È¤@Pªº³q¥Î¦P¨B¬[ºc¶}©l¡AµM¦Z§ÚÌ·| ²`¤J±´°Q¦p¦ó¦bCore Data¤¤¦P®É¨Ï¥Î¦hÓ¦«ºÞ¹ï¶H¤W¤U¤å(managed object context)¡C§ÚÌ ´£¥X³]¸mCore Data´Ìªº¤£¦P¤è®×¡A¦}°Q½×¤F¥¦ÌªºÀu¯ÊÂI¡C¦b²Ä9³¹¨½¡A¤¶²Ð¤F¦p¦óÀ³¹ï ¦P®É¨Ï¥Î¦hÓ¤W¤U¤å±a¨ÓªºÃB¥~´_Âø©Ê¡C ²Ä¥|³¡¤À¯A¤Î¤@¨Ç°ª¯Åªº¥DÃD¡A¤ñ¦p°ª¯Åªº¿×µü(predicate)¡B·j¯Á©M¤å¥»±Æ§Ç¡B¦p¦ó¦b¤£¦P ªº¼Æ¾Ú¼Ò«¬ª©¥»¤§¶¡¾E²¾¼Æ¾Ú¡A¥H¤Î¤ÀªRCore Data´Ìªº©Ê¯à®É©Ò»Ýnªº¤u¨ã©M§Þ³Nµ¥¡C³o ³¡¤À¤¤¦³¤@³¹¬O±qCore Dataµø¨¤¤¶²Ð¦³ÃöÃö¨t¼Æ¾Ú®w©MSQL¬d¸ß»y¨¥ªº°ò¥»ª¾ÃѪº¡C¦pªG §A¤£¼ô±x³o¨Ç¤º®e¡A¨º¤\³o¨Ç³¹¸`¯à¹ï§A¦³©ÒÀ°§U¡A¯S§O¬O¥i¥HÅý§A²z¸ÑCore Data¼ç¦bªº ©Ê¯à°ÝÃD¡A¥H¤Î¸Ñ¨M³o¨Ç°ÝÃD©Ò»Ýnªº¤ÀªR§Þ³N¡C Ãö¤_Swiftªº¤@¨Ç»¡©ú ³e¬ï¥»®Ñ¡A§ÚÌ©Ò¦³ªº¥Ü¨Ò³£¨Ï¥ÎSwiû@½s¼g¡C§Ú̾֩êSwiû@ªº»y¨¥¯S©Ê¡X¡X¤ñ¦pªx«¬¡B¨óij¥H¤ÎÂX®i¡X¡X¥¦Ì¯àÅý§Ú̧óÀu¶®¡B²³æ¡B¦w¥þ¦a¨Ï¥ÎCore DataªºAPI¡C ¥ÎSwiû@ªí¥Üªº³Ì¨Î¹ê½î©M³]p¼Ò¦¡¦P¼Ë¤]¾A¥Î¤_Objective-Cªº¥N½X¡C¦b¹ê²{¤W¡A¥Ñ¤_»y¨¥¤Wªº¤£¦P¡A©Î³\¦b¬Y¨Ç¤è±·|µy¦³¤£¦P¡A¦ý¬O©³¼hªºì«h¬O¬Û³qªº¡C ¥i¿ïȪº¬ù©w Swiû@´£¨Ñ¤FOptional¼Æ¾ÚÃþ«¬¡A³o¢¨Ï§ÚÌÅ㦡¦a«ä¦Ò©M³B²z¨S¦³Èªº±¡ªp¡C§ÚÌ«D±`³ß Åw³oÓ¥\¯à¡A©Ò¥H§Ú̦b©Ò¦³ªº¨Ò¤l¨½³£¨Ï¥Î¤F¥¦¡C ¦]¦¹§Ú̺ɶqÁקK¨Ï¥Î Swiû@ ªº ! ¾Þ§@²Å¨Ó±j¨î¸Ñ¥] (¥]¬A¥Î¥¦¨Ó©w¸qÁô¦¡¸Ñ¥]Ãþ«¬ªº¥Îªk)¡A¦b§Ú̬ݨӳo¬O¤@ºØÃa¥N½Xªº¨ý¹D¡A¦]¬°¥¦¯}Ãa¤F§Ų́ϥΥi¿ïÈÃþ«¬©Ò±a¨ÓªºÃþ«¬¦w¥þ¡C °ß¤@ªº¨Ò¥~¬O¨º¨Ç¥²¶·³]¸m¦ý¤SµLªk¦bªì©l¤Æ®É³]¸mªºÄÝ©Ê¡C¤ñ¦p Interface Builder ªº outlets©Î¥²nªº¥N²z(delegate)Äݩʵ¥¡C¦b³o¨Ç±¡ªp¤U¡A¨Ï¥ÎÁô¦¡¸Ñ¥]ªº¥i¿ïȲŦX¡§ºÉ¦ ±Y¼ì¡¨ì«h¡G§ÚÌ·|¥ß¨èª¾¾å³o¨Ç¥²¶·n³]¸m¦Ó¤S¨S¦³¥¿½T³]¸mªºÄÝ©Ê¡C ¿ù»~³B²zªº¬ù©w Core Data¤¤³\¦h¤èªk·|©ß¥X¿ù»~¡C°ò¤_¥¦Ì¬O¤£¦PÃþ«¬ªº¿ù»~³o¤@°ò¥»¨Æ¹ê¡A§ÚÌ¥i¥H¤À Ãþ³B²z³o¨Ç¿ù»~¡C§Ú̱N°Ï¤ÀÅÞ¿è¿ù»~©M¨ä¥L¿ù»~¡C ÅÞ¿è¿ù»~¬O«üµ{§Çû¥Ç¿ùªºµ²ªG¡C¥¦ÌÀ³¸Ó±q¥N½X¼h±¤W×´_¦Ó¤£À³¸Ó¹Á¸Õ°ÊºA«ì´_µ{§Ç ªº¹B¦æ¡C Á|¤@Ó¨Ò¤l¡A·í§A¹Á¸ÕŪ¨úÀ³¥Îµ{§Ç¥]¨½ªº¤@Ó¤å¥ó®É¡A¦]¬°À³¥Îµ{§Ç¥]¬O¥uŪªº¡A¨º¤\ ¤@Ó¤å¥ón¤\¦s¦b¡An¤\¤£¦s¦b¡A¦Ó¥B¥¦ªº¤º®e¥Ã»·¤£·|ÅÜ¡C©Ò¥H¦pªG§Ú̵Lªk¥´¶}©ÎªÌ ¸ÑªRÀ³¥Îµ{§Ç¥]¨½ªº¤å¥ó¡A¨º¤\³o´N¬O¤@ÓÅÞ¿è¿ù»~¡C ¹ï¤_³o¨ÇÃþ«¬ªº¿ù»~¡A§Ų́ϥΠSwiû@ ªº try! ©Î fatalError() ¨ÓºÉ¥i¯à¦¦aÅýÀ³¥Îµ{§Ç ±Y¼ì¡C ¦P¼Ëªº«ä·Q¥i¥H¾A¥Î¤_ as! ¾Þ§@²Åªº±j¨îÃþ«¬Âà´«: ¦pªG§Ú̪¾¹D¤@Ó¹ï¶H¥²¶·¬O¬YºØÃþ «¬¡AÂà´«¥¢±Ñªº°ß¤@ì¦]·|¬OÅÞ¿è¿ù»~¡A¨º¤\¦b³oºØ®ÉÔ§Ú̹ê»Ú¤W¬O§Æ±æÀ³¥Îµ{§Ç±Y ¼ìªº¡C «Ü¦h®ÉÔ§Ú̥ΠSwiû@ ªº guard ÃöÁä¦r¨Ó§ó¦n¦aªí¹Fþ¨Ç¦a¤è¥X¿ù¤F¡C¨Ò¦p fetched results controllerªð¦^ªºÃþ«¬¬ONSManagedObjectªº¹ï¶H¡A§Ú̪¾¹D¥¦¥²¶·¬O¤@Ó¯S©wªº¤lÃþ¡A§Ú ̨ϥÎguard¨Ó«OÃÒ¦V¤UÂà´«¡A¦}¦b¥X¿ùªº®ÉԨϥÎfatal error¨Ó¤¤¤îµ{§Ç: func objectAtIndexPath(indexPath: NSIndexPath) -¡Ö Object { guard let result = fetchedResultsController.objectAtIndexPath(indexPath) as? Object else { fatalError("Unexpected object at (indexPath)") } return result } ¹ï¤_¥i«ì´_ªº«DÅÞ¿è©Ê¿ù»~¡A§Ų́ϥÎSwiû@ªº¿ù»~¶Ç»¼¤èªk¡G©ß¥X(throw)©ÎªÌ«·s©ß¥X (rethrow)³o¨Ç¿ù»~¡C
Florian Daniel |
¤º®e²¤¶¡G¥»®Ñ¦VŪªÌ¤¶²Ð¨Ï¥ÎCore Data®É»Ýn¯S§Oª`·Nªº¨Æ¶µ¡A³o±NÀ°§UŪªÌÁ׶}¨Ï¥ÎCore Data³oÓ¤Q¤ÀÆF¬¡¥B²§±`±j¤jªº®Ø¬[®Éªº¤@¨Ç³´¨À¡C§Ú̱q¤@Ó²³æªºÀ³¥Î¨Ò¤l¶}©l¡A³v¨B±N¨äÂX®i¬°¥]§tÃö¨t¡B°ª¯Å¼Æ¾ÚÃþ«¬¡B¦}µo¡B¦P¨B¥H¤Î¨ä¥L«Ü¦h¯S©Êªº§¹¾ã¨Ò¤l¡A¦}¦b³oÓ¹Lµ{¤¤¹ï©Ò¦³³o¨Ç¥DÃD¶i¦æÁ¿¸Ñ¡C¦b¥»®Ñ¦Z¥b³¡¤À¡A§ÚÌÁÙ·|¶W¥X³oÓ°ò¥»À³¥Î©Ò»Ýn¯A¤ÎªºS³ò¡A±Nª¾ÃÑÂI²`¤JÂX®i¨ìCore Data¹õ¦Zªº¤u§@ì²z¤W¡C§ÚÌ·|¾Ç²ß¦p¦óÀò¨ú°ª©Ê¯à¡B¤£¦PCore Data³]¸m¤§¶¡ªºÅv¿Å¡A¥H¤Î¦p¦ó¹ïCore Data¥N½X¶i¦æ½Õ¸Õ©M©Ê¯à´ú¸Õ¡C¥»®Ñ©Ò¦³ªº¥N½X³£¨Ï¥ÎSwift½s¼g¡A§Ṳ́]®i¥Ü¤F¦p¦ó±NSwiftªº»y¨¥¯S©Ê¿Ä¤JCore Data¤¤¡A¦}¼g¥XÀu¶®©M¦w¥þªº¥N½X¡C§Ú̧ƱæŪªÌ¦b¾\Ū¥»®Ñªº®ÉÔ¦³¤@©wªºSwift©MiOS¶}µo°ò¦¡A¤£¹L¬Û«H¤£½×¬O·s¤HÁÙ¬O´I¦³¸gÅ窺¶}µoªÌ¡A³£¯à±q¥»®Ñ¤¤§ä¨ì¹ê¥Îªº«H®§©M³]p¼Ò¦¡¡C |
¥Ø¿ý¡GI Core Data°ò¦ 1 ²Ä1³¹ ªì±´Core Data 2 1.1 Core Data¬[ºc 2 1.2 ¼Æ¾Ú«Ø¼Ò 4 ¹êÅé©MÄÝ©Ê 5 ¦«ºÞ¹ï¶H¤lÃþ 6 1.3 ³]¸mCore Data´Ì 7 1.4 Åã¥Ü¼Æ¾Ú 9 Àò¨ú½Ð¨D 11 Fetched Results Controller 13 1.5 ¾Þ§@¼Æ¾Ú 19 ´¡¤J¹ï¶H 19 §R°£¹ï¶H 22 1.6 Á`µ² 26 «ÂI 26 ²Ä2³¹ Ãö¨t 27 2.1 ²K¥[Country©MContinent¹êÅé 27 ¤l¹êÅé 31 2.2 ³Ð«ØÃö¨t 33 ¨ä¥LÃþ«¬ªºÃö¨t 35 «Ø¥ßÃö¨t 36 Ãö¨t©M§R°£ 41 2.3 ¾A°t¥Î¤á¬É± 43 2.4 Á`µ² 48 «ÂI 48 ²Ä3³¹ ¼Æ¾ÚÃþ«¬ 49 3.1 ¼Ð·Ç¼Æ¾ÚÃþ«¬ 49 ¼ÆÈÃþ«¬ 49 ¤é´Á 50 ¤G¶i¨î¼Æ¾Ú 50 ¦r²Å¦ê 51 3.2 ì©lÄÝ©Ê©MÁ{®ÉÄÝ©Ê 51 ì©lÄÝ©Ê 51 Á{®ÉÄÝ©Ê 52 3.3 ¦Û©w¸q¼Æ¾ÚÃþ«¬ 52 ¦Û©w¸qÈÂà´«¾¹ 52 ¦Û©w¸q¦s¨ú¤èªk 56 3.4 Àq»{È©M¥i¿ïÈ 59 3.5 Á`µ² 60 «ÂI 60 II ²z¸ÑCore Data 61 ²Ä4³¹ ³X°Ý¼Æ¾Ú 62 4.1 Àò¨ú½Ð¨D 62 ¹ï¶H´kÈ 64 Àò¨ú½Ð¨Dªºµ²ªGÃþ«¬ 67 §å¶qÀò¨ú 69 ²§¨BÀò¨ú½Ð¨D 70 4.2 Ãö¨t 70 4.3 ¨ä¥L¨ú¦^¦«ºÞ¹ï¶Hªº¤èªk 71 4.4 ¤º¦s¦Ò¶q 72 ¦«ºÞ¹ï¶H¤Î¨ä¤W¤U¤å 72 Ãö¨tªº´`Àô¤Þ¥Î 73 4.5 Á`µ² 74 «ÂI 74 ²Ä5³¹ §ó§ï©M«O¦s¼Æ¾Ú 76 5.1 Åܧó°lÂÜ 76 5.2 «O¦s§ó§ï 78 ÅçÃÒ 80 «O¦s¨R¬ð 82 5.3 §å¶q§ó·s 82 5.4 Á`µ² 84 «ÂI 84 ²Ä6³¹ ©Ê¯à 86 6.1 Core Data´Ìªº©Ê¯à¯S½è 86 ¸Ô¸Ñ©Ê¯à 87 6.2 ÁקKÀò¨ú½Ð¨D 89 Ãö¨t 89 ·j¯Á¯S©wªº¹ï¶H 91 Ãþ¦ü³æ¨Òªº¹ï¶H 93 ¤p¼Æ¾Ú¶° 96 6.3 Àu¤ÆÀò¨ú½Ð¨D 96 ¹ï¶H±Æ§Ç 96 ÁקK¦hÓ¡B³sÄòªº´kÈ 97 §å¶qÀò¨ú 98 Fetched Results Controller 99 Ãö¨t¹w¥[¸ü 99 ¯Á¤Þ 100 6.4 ´¡¤J©Mקï¹ï¶H 102 6.5 ¦p¦óºc«Ø°ª®Äªº¼Æ¾Ú¼Ò«¬ 103 6.6 ¦r²Å¦ê©M¤å¥» 106 6.7 ¿W®a¯µ³Zªº¥i½Õ°Ñ¼Æ 106 6.8 Á`µ² 107 III ¦}¦æ©M¦P¨B 109 ²Ä7³¹ »Pºôµ¸ªA°È¦P¨B 110 7.1 ²Õ´©M³]¸m 110 ¶µ¥Øµ²ºc 111 7.2 ¦P¨B¬[ºc 112 7.3 ¤W¤U¤åÄÝ¥D 113 ½uµ{¡B¶¤¦C©M¤W¤U¤å 113 7.4 ÅTÀ³¥»¦a§ó§ï 115 7.5 ÅTÀ³»·µ{§ó§ï 119 7.6 §ó§ï³B²z¾¹ 119 ¤W¶ÇMoods 120 7.7 §R°£¥»¦a¹ï¶H 123 7.8 ¤À²Õ©M«O¦s§ó§ï 123 7.9 ÂX®i¦P¨B¬[ºc 125 ¸òÂܨCÓÄݩʪº§ó§ï 125 Ãì±µ§ó§ï³B²z¾¹ 125 ¦Û©w¸qºôµ¸¥N½X 126 ²Ä8³¹ ¨Ï¥Î¦hÓ¤W¤U¤å 128 8.1 Core Data©M¦}µo 128 ¦b¤£¦Pªº¤W¤U¤å¤§¶¡¶Ç»¼¹ï¶H 130 ¦X¦}§ó§ï 132 8.2 Core Data´Ì 134 ¨âÓ¤W¤U¤å¡A¤@Ó¨ó½Õ¾¹ 134 ¨âÓ¨ó½Õ¾¹ 136 ´O®M¤W¤U¤åªº³]¸m 137 8.3 Á`µ² 144 «ÂI 145 ²Ä9³¹ ¨Ï¥Î¦hÓ¤W¤U¤åªº°ÝÃD 146 9.1 «O¦s¨R¬ð 146 ¹w©w¸qªº¦X¦}µ¦²¤ 147 ¦Û©w¸q¦X¦}µ¦²¤ 148 9.2 §R°£¹ï¶H 153 ¨â¨B§R°£ªk 154 ¶Ç¼½§R°£ 156 9.3 °ß¤@©Ê¬ù§ô 157 9.4 Á`µ² 159 IV ¶i¶¥¸ÜÃD 161 ²Ä10³¹ ¿×µü 162 10.1 ¤@Ó²³æªº¨Ò¤l 162 ¨Ï¥Î¿×µü 163 10.2 ¥Î¥N½X¨Ó³Ð«Ø¿×µü 164 10.3 ®æ¦¡¦r²Å¦ê 165 ¤ñ¸û 166 ¥i¿ïÃþ«¬È 167 ¤é´Á 168 10.4 ¦X¦}¦hÓ¿×µü 168 ±`¶q¿×µü 170 10.5 ¹M¾úÃö¨t 171 ¤l¬d¸ß 171 10.6 ¤Ç°t¹ï¶H©M¹ï¶HID 172 10.7 ¤Ç°t¦r²Å¦ê 173 ¦r²Å¦ê©M¯Á¤Þ 175 10.8 ¥iÂà´«ªºÈ 175 10.9 ©Ê¯à©M±Æ§Çªí¹F¦¡ 176 10.10 Á`µ² 177 ²Ä11³¹ ¤å¥» 178 11.1 ¤@¨Ç¨Ò¤l 178 11.2 ·j¯Á 179 ¦r²Å¦ê¼Ð·Ç¤Æ 180 °ª®Ä·j¯Á 182 11.3 ±Æ§Ç 183 ¤@ºØ²³æªº¤èªk 183 §ó·s¤@Ó¤w±Æ§Çªº¼Æ²Õ 184 «ù¤[¤Æ¤@Ó¤w±Æ§Çªº¼Æ²Õ 188 11.4 Á`µ² 189 «ÂI 189 ²Ä12³¹ ¼Æ¾Ú¼Ò«¬ª©¥»¥H¤Î¾E²¾¼Æ¾Ú 190 12.1 ¼Æ¾Ú¼Ò«¬ª©¥» 190 12.2 ¼Æ¾Ú¾E²¾ªº¹Lµ{ 192 ¦Û°Ê¼Æ¾Ú¾E²¾ 193 ¤â°Ê¼Æ¾Ú¾E²¾ 194 12.3 ±ÀÂ_ªº¬M®g¼Ò«¬ 201 12.4 ¦Û©w¸q¬M®g¼Ò«¬ 202 ¦Û©w¸q¹êÅé¬M®gµ¦²¤ 204 12.5 ¼Æ¾Ú¾E²¾©M¥Î¤á¬É± 206 12.6 ´ú¸Õ¼Æ¾Ú¾E²¾ 209 ½Õ¸Õ¼Æ¾Ú¾E²¾®Éªº¿é¥X 210 12.7 Á`µ² 210 «ÂI 211 ²Ä13³¹ ©Ê¯à¤ÀªR 212 13.1 SQL½Õ¸Õ¿é¥X 212 Àò¨ú½Ð¨D 213 ¶ñ¥R´kÈ 217 «O¦s¼Æ¾Ú 218 13.2 Core Data Instruments 219 13.3 ½uµ{«OÅ@ 222 13.4 Á`µ² 222 ²Ä14³¹ Ãö¨t«¬¼Æ¾Ú®w°ò¦©MSQL 223 14.1 ¤@Ó´O¤J¦¡¼Æ¾Ú®w 223 14.2 ¼Æ¾Úªí¡B¦C¥H¤Î¦æ 224 14.3 ¼Æ¾Ú®w¨t²Îªºµ²ºc 225 ¬d¸ß³B²z¾¹ 225 ¦sÀxºÞ²z¾¹ 226 ¨Æ°ÈºÞ²z¾¹ 226 ¼Æ¾Ú©M¤¸¼Æ¾Ú 226 14.4 ¼Æ¾Ú®w»y¨¥SQL 227 ±Æ§Ç 228 14.5 Ãö¨t 229 ¤@¹ï¤@Ãö¨t 229 ¤@¹ï¦hÃö¨t 230 ¦h¹ï¦hÃö¨t 230 14.6 ¨Æ°È 231 14.7 ¯Á¤Þ 232 14.8 ¤é§Ó 232 14.9 Á`µ² 233 |
§Ç¡G |