CoreDataã䜿çšããŠããŒã¿ãã¢ããªã±ãŒã·ã§ã³ã«æ ŒçŽãå§ãããšãåäžã®ç®¡ç察象ã³ã³ããã¹ãïŒMOCïŒã§äœæ¥ãéå§ããŸãã ããã¯ããããžã§ã¯ããäœæãããšãã«ãã³ã¢ããŒã¿ã䜿çšãããã®æšªã®ããã¯ã¹ããªã³ã«ããå ŽåãxCodeã§ãããžã§ã¯ããäœæãããšãã«ãã³ãã¬ãŒãã§äœ¿çšããããã®ã§ãã
CoreDataãNSFetchedResultsControllerãšçµã¿åãããŠäœ¿çšââãããšãããŒãã«ãã¥ãŒã®ç»é¢ã«è¡šç€ºãããããããçš®é¡ã®ã¢ã€ãã ã®ãªã¹ãã§ã®äœæ¥ãå€§å¹ ã«ç°¡çŽ åãããŸãã
åå²ãããã·ããªãªã2ã€ãããŸãã å¶åŸ¡ãããè€æ°ã®å®¢èŠ³çã³ã³ããã¹ãã®äœ¿çšïŒ1ïŒæ°ããèŠçŽ ã®è¿œå /ç·šéã®ããã»ã¹ãç°¡çŽ åãã2ïŒUIã®ãããã¯ãåé¿ããŸãã ãã®æçš¿ã§ã¯ãå¿ èŠãªãã®ãååŸããããã«ãã³ã³ããã¹ããäœæããæ¹æ³ãæ€èšããŸãã
æåã«ãåäžã®ã³ã³ããã¹ãã®èšå®ãèŠãŠã¿ãŸãããã ãã£ã¹ã¯äžã®ããŒã¿ããŒã¹ãã¡ã€ã«ã«ã¢ã¯ã»ã¹ããã«ã¯ãæ°žç¶ã¹ãã¢ã³ãŒãã£ããŒã¿ãŒïŒPSCïŒãå¿ èŠã§ãã ãã®ã³ãŒãã£ããŒã¿ãŒããã®ããŒã¿ããŒã¹ã®æ§é ãç解ããã«ã¯ãã¢ãã«ãå¿ èŠã§ãã ãã®ã¢ãã«ã¯ããããžã§ã¯ãã«å«ãŸãããã¹ãŠã®ã¢ãã«å®çŸ©ããçµåããããã®ããŒã¿ããŒã¹æ§é ã«ã€ããŠCoreDataã«ç€ºããŸãã ã³ãŒãã£ããŒã¿ãŒã¯ãé¢æ°ããããã£ãä»ããŠãããŒãžã³ã³ããã¹ããªããžã§ã¯ãã«ã€ã³ã¹ããŒã«ãããŸãã æåã®ã«ãŒã«ãèŠããŠãããŠãã ããïŒsaveContextãåŒã³åºããšã管ç察象ã®ã³ã³ããã¹ããã³ãŒãã£ããŒã¿ãŒã䜿çšããŠãã£ã¹ã¯ã«æžã蟌ãŸããŸãã
ãã®ã¹ããŒã ãæ€èšããŠãã ããã ãã®åäžã®å¶åŸ¡ããã客芳çã³ã³ããã¹ãã§ãšã³ãã£ãã£ãæ¿å ¥ãæŽæ°ããŸãã¯åé€ãããã³ã«ãéžæãããçµæã³ã³ãããŒã©ãŒã«ãããã®å€æŽãéç¥ãããããŒãã«ãã¥ãŒã®ã³ã³ãã³ããæŽæ°ãããŸãã ããã¯ãã³ã³ããã¹ãã®ä¿åãšã¯ç¡é¢ä¿ã§ãã ãŸãã«ããŸãã¯å¿ èŠã«å¿ããŠäœåºŠã§ãä¿åã§ããŸãã Appleãã³ãã¬ãŒãã¯ããšã³ãã£ãã£ã®è¿œå ããšã«ä¿åãããapplicationWillTerminateã«ãä¿åãããŸãïŒå¥åŠã§ã¯ãããŸããïŒã
ãã®ã¢ãããŒãã¯äž»ã«ã»ãšãã©ã®åºæ¬çãªã±ãŒã¹ã«é©ããŠããŸãããåè¿°ããããã«ã2ã€ã®åé¡ããããŸãã 1ã€ã¯ãæ°ãããšã³ãã£ãã£ã®è¿œå ã«é¢é£ããŠããŸãã ããããããšã³ãã£ãã£ãè¿œå ããã³ç·šéããããã«ãåã趣å³/èŠèŠçè¡šçŸãå床䜿çšãããã§ãããã ãããã£ãŠããã¥ãŒã®èŠèŠåãèšå ¥ããåã§ããæ°ãããšã³ãã£ãã£ãäœæããããšãã§ããŸãã ããã«ãããæŽæ°éç¥ã«ãããéžæããçµæã®ã³ã³ãããŒã©ãŒã§æŽæ°ãéå§ãããŸãã MVCã³ã³ã»ãããè¿œå ãŸãã¯ç·šéã®ããã«å®å šã«è¡šç€ºãããå°ãåã«ã空ã®è¡ã衚瀺ãããŸãã
2çªç®ã®åé¡ã¯ãsaveContextãé床ã«å€§ãããªãåã«æŽæ°ãèç©ãããä¿åæäœã1/60ç§ãããé·ããããå Žåã«æããã«ãªããŸãã ãã®å ŽåããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã¯ä¿åãå®äºãããŸã§ãããã¯ãããã¹ã¯ããŒã«ãªã©ã®éèŠãªç§»è¡ãçºçããããã§ãã
äž¡æ¹ã®åé¡ã¯ãããã€ãã®å¶åŸ¡ããã客芳çãªã³ã³ããã¹ãã䜿çšããŠè§£æ±ºã§ããŸãã
ãåŸæ¥ã®ããã«ãã³ã³ããã¹ãã¢ãããŒã
管çãããå客芳çã³ã³ããã¹ãã¯ãäžæçãªå€åã®ããããšèããŠãã ããã iOS 5ã®ãªãªãŒã¹åã¯ãããããä»ã®ã³ã³ããã¹ãã®å€æŽã«ã€ããŠèããŠãããéç¥ã®ç¬éããã®å€æŽãã¡ã€ã³ã³ã³ããã¹ãã«ããŒãžããŠããŸããã äžè¬çãªã€ã³ã¹ããŒã«ã¯ã次ã®ãããã¯å³ã®ããã«ãªããŸãã
ããã¯ã°ã©ãŠã³ãã¿ã¹ã¯ãã¥ãŒã«äœ¿çšããäžæã³ã³ããã¹ããäœæããŸãã ãããŠãããã«å€æŽãä¿åããã¡ã€ã³ã³ã³ããã¹ããšåãããã«ãäžæã³ã³ããã¹ãã«åãæ°žç¶ã¹ãã¬ãŒãžã³ãŒãã£ããŒã¿ãŒãèšå®ããŸãã Marcus Sarrã«ãããšã次ã®ããã«ãªããŸãã
NSPersistentStoreCoordinatorã¯ã¹ã¬ããã»ãŒãã§ã¯ãããŸããããNSManagedObjectContextã¯äœ¿çšäžã«é©åã«ããã¯ããæ¹æ³ãç¥ã£ãŠããŸãã ãããã£ãŠãè¡çªãæããããšãªããå¿ èŠãªã ãNSManagedObjectContextãªããžã§ã¯ããNSPersistentStoreCoordinatorã«ã¢ã¿ããã§ããŸãã
ããã¯ã°ã©ãŠã³ãã³ã³ããã¹ãã§saveContextãåŒã³åºããšããªããžããªãã¡ã€ã«ã«å€æŽãæžã蟌ãŸããNSManagedObjectContextDidSaveNotificationãéå§ãããŸãã
ã³ãŒãã§ã¯ã次ã®ããã«ãªããŸãã
dispatch_async(_backgroundQueue, ^{ // create context for background NSManagedObjectContext *tmpContext = [[NSManagedObjectContext alloc] init]; tmpContext.persistentStoreCoordinator = _persistentStoreCoordinator; // something that takes long NSError *error; if (![tmpContext save:&error]) { // handle error } });
äžæçãªã³ã³ããã¹ãã®äœæã¯éåžžã«é«éã§ããããããããã®äžæçãªã³ã³ããã¹ãã®é »ç¹ãªäœæãšãªãªãŒã¹ã«ã€ããŠå¿é ããå¿ èŠã¯ãããŸããã ãã€ã³ãã¯ãpersistentStoreCoordinatorãåãã¡ã€ã³ã³ã³ããã¹ãã«èšå®ãããããäœæãããã¯ã°ã©ãŠã³ãã§è¡ãå¿ èŠãããããšã§ãã
CoreDataã¹ã¿ãã¯ã®ãã®åçŽåãããã€ã³ã¹ããŒã«ã奜ãã§ãïŒ
- (void)_setupCoreDataStack { // setup managed object model NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Database" withExtension:@"momd"]; _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; // setup persistent store coordinator NSURL *storeURL = [NSURL fileURLWithPath:[[NSString cachesPath] stringByAppendingPathComponent:@"Database.db"]]; NSError *error = nil; _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:_managedObjectModel]; if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { // handle error } // create MOC _managedObjectContext = [[NSManagedObjectContext alloc] init]; [_managedObjectContext setPersistentStoreCoordinator:_persistentStoreCoordinator]; // subscribe to change notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_mocDidSaveNotification:) name:NSManagedObjectContextDidSaveNotification object:nil]; }
ããã§ãdidSaveéç¥ãæ¯åãããã¢ããããããã«èšå®ããéç¥ãã³ãã©ãŒãæ€èšããŸãã
- (void)_mocDidSaveNotification:(NSNotification *)notification { NSManagedObjectContext *savedContext = [notification object]; // ignore change notifications for the main MOC if (_managedObjectContext == savedContext) { return; } if (_managedObjectContext.persistentStoreCoordinator != savedContext.persistentStoreCoordinator) { // that's another database return; } dispatch_sync(dispatch_get_main_queue(), ^{ [_managedObjectContext mergeChangesFromContextDidSaveNotification:notification]; }); }
ãŸããç¬èªã®å€æŽãããŒãžããªãããã«ããŸãã ãŸããåãã¢ããªã±ãŒã·ã§ã³ã«è€æ°ã®CoreDataããŒã¿ããŒã¹ãããå Žåãå¥ã®ããŒã¿ããŒã¹ã察象ãšããå€æŽã®ããŒãžãåé¿ããããšããŸãã ã¢ããªã±ãŒã·ã§ã³ã®1ã€ã§ãã®ãããªåé¡ãçºçãããããæ°žç¶ã¹ãã¬ãŒãžã®ã³ãŒãã£ããŒã¿ãŒã確èªããŸãã æåŸã«ãmergeChangesFromContextDidSaveNotificationã¡ãœããã䜿çšããŠå€æŽãããŒãžããŸãã éç¥ã«ã¯ãã€ããŒãã®ãã¹ãŠã®å€æŽã®èŸæžãããããã®ã¡ãœããã¯ããããã³ã³ããã¹ãã«çµ±åããããšãç¥ã£ãŠããŸãã
ã³ã³ããã¹ãéã§ç®¡ç察象ãªããžã§ã¯ããæž¡ã
åãåã£ã管ç察象ãªããžã§ã¯ããããã³ã³ããã¹ãããå¥ã®ã³ã³ããã¹ãã«ç§»åããããšã¯åºãçŠããããŠããŸãã ObjectIDãä»ããŠç®¡ç察象ãªããžã§ã¯ãã®ããã©ãŒããåŠçããç°¡åãªæ¹æ³ããããŸãã ãã®èå¥åã¯ã¹ã¬ããã»ãŒãã§ãããNSManagedObjectã®1ã€ã®ã€ã³ã¹ã¿ã³ã¹ãããã€ã§ãååŸã§ããobjectWithIDãåŒã³åºãããšãã§ããŸãã 2çªç®ã®ã³ã³ããã¹ãã¯ã管ç察象ãªããžã§ã¯ãã®ç¬èªã®ã³ããŒãåä¿¡ããŠââããããæäœããŸãã
NSManagedObjectID *userID = user.objectID; // make a temporary MOC dispatch_async(_backgroundQueue, ^{ // create context for background NSManagedObjectContext *tmpContext = [[NSManagedObjectContext alloc] init]; tmpContext.persistentStoreCoordinator = _persistentStoreCoordinator; // user for background TwitterUser *localUser = [tmpContext objectWithID:userID]; // background work });
説æããã¢ãããŒãã¯ãiOS 3ã§CoreDataã®ãµããŒããåããiOSã®æåã®ããŒãžã§ã³ãŸã§å®å šã«äžäœäºææ§ããããŸããã¢ããªã±ãŒã·ã§ã³ã§iOS 5ã®ãµããŒãã®ã¿ãå¿ èŠãªå Žåã¯ãããçŸä»£çãªã¢ãããŒãããããŸãã
芪/åã³ã³ããã¹ã
IOS 5ã§ã¯ã管ç察象ãªããžã§ã¯ãã³ã³ããã¹ãã«parentContextãå«ããæ©èœãå°å ¥ãããŠããŸãã saveContextã¡ãœãããåŒã³åºããšãå€æŽãèšè¿°ãããã£ã¯ã·ã§ããªã®ã³ã³ãã³ããããŒãžããã¡ãœããã«é Œãå¿ èŠãªããåã³ã³ããã¹ããã芪ã«å€æŽãããã·ã¥ãããŸãã åæã«ãAppleã¯ãã³ã³ããã¹ããåæããã³éåæã®äž¡æ¹ã§å€æŽãè¡ãããã®ç¬èªã®åå¥ã®ãã¥ãŒãæã€æ©èœãè¿œå ããŸããã
ãã¥ãŒã®åæå®è¡ã®ã¿ã€ãã¯ãNSManagedObjectContextã®æ°ããåæååinitWithConcurrencyTypeã§èšå®ãããŸãã ãã®å³ã§ã¯ãè€æ°ã®åã³ã³ããã¹ããè¿œå ãããããå šå¡ã芪ãšåãã¡ã€ã³ã³ã³ããã¹ããã¥ãŒãæã€ããšã«æ³šæããŠãã ããã
ä¿åãããã³ã«ãåã³ã³ããã¹ãã¯ãã®èŠªãžã®å€æŽãä¿åãããããéžæããçµæã®ã³ã³ãããŒã©ãŒããããã®å€æŽãèªèããŠããå¿ èŠããããŸãã ãã ããããã¯ã°ã©ãŠã³ãã³ã³ããã¹ãã¯æ°žç¶ã¹ãã¬ãŒãžã³ãŒãã£ããŒã¿ãŒãèªèããªããããããã§ãããŒã¿ã¯ä¿åãããŸããã ãã£ã¹ã¯ã«ããŒã¿ãååŸããã«ã¯ãã¡ã€ã³ã³ã³ããã¹ããã¥ãŒã«è¿œå ã®saveContextã¡ãœãããå¿ èŠã§ãã
ãã®ã¢ãããŒãã§æåã«å¿ èŠãªå€æŽã¯ãã¡ã€ã³ã®äžŠè¡æ§ã¿ã€ãã®ã³ã³ããã¹ããNSMainQueueConcurrencyTypeã«å€æŽããããšã§ãã åè¿°ã®_setupCoreDataStackã§ã¯ãæåã®è¡ã®å€æŽã¯æ¬¡ã®ããã«ãªããããŒãžéç¥ãåä¿¡ããå¿ èŠããªããªããŸããã
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; [_managedObjectContext setPersistentStoreCoordinator:_persistentStoreCoordinator];
é·ãããã¯ã°ã©ãŠã³ãæäœã¯æ¬¡ã®ããã«ãªããŸãã
NSMangedObjectContext *temporaryContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; temporaryContext.parentContext = mainMOC; [temporaryContext performBlock:^{ // do something that takes some time asynchronously using the temp context // push to parent NSError *error; if (![temporaryContext save:&error]) { // handle error } // save parent to disk asynchronously [mainMOC performBlock:^{ NSError *error; if (![mainMOC save:&error]) { // handle error } }]; }];
åã³ã³ããã¹ãã§ã¯ãåäœããããã«performBlockïŒïŒasyncïŒãŸãã¯performBlockAndWaitïŒïŒsyncïŒã䜿çšããå¿ èŠããããŸãã ããã«ããããããã¯ã«å«ãŸããæäœãæ£ãããã¥ãŒã䜿çšããããšãä¿èšŒãããŸãã äžèšã®äŸã§ã¯ãããã¯ã°ã©ãŠã³ããã¥ãŒã§é·ãæäœãå®è¡ãããŸãã ãã¹ãŠã®æºåãæŽããå€æŽãsaveContextã¡ãœãããä»ããŠèŠªã«ãªãã€ã¬ã¯ãããããšããã«ãperformBlockéåæã¡ãœããã衚瀺ãããmainMOCãä¿åãããŸãã ãããŠãperformBlockãæäŸããããã«ãæ£ãããã¥ãŒã§åã³çºçããŸãã
芪ãšã¯ç°ãªããåã³ã³ããã¹ãã¯èªåçã«æŽæ°ãããŸããã å床ããŠã³ããŒãããŠæŽæ°ãåãåãããšãã§ããŸãããã»ãšãã©ã®å Žåããããã¯äžæçãªãã®ã§ãããããå¿é ããå¿ èŠã¯ãããŸããã ã¡ã€ã³ã³ã³ããã¹ããã¥ãŒãå€æŽãåä¿¡ããéããéžæããçµæã®ã³ã³ãããŒã©ãŒãæŽæ°ãããã¡ã€ã³ã³ã³ããã¹ããç¶æããªããæ°žç¶æ§ã確ä¿ãããŸãã
ãã®ã¢ãããŒãã«ãã£ãŠæäŸãããé©ãã¹ãç°¡çŽ åã¯ã[ä¿å]ãã¿ã³ãš[ãã£ã³ã»ã«]ãã¿ã³ããããã¥ãŒããžã¥ã¢ã©ã€ãŒãŒã·ã§ã³ã®äžæçãªã³ã³ããã¹ããïŒåãšããŠïŒäœæã§ããããšã§ãã 管çãªããžã§ã¯ããç·šéçšã«æž¡ãå ŽåãïŒäžèšã®objectIDãä»ããŠïŒäžæã³ã³ããã¹ãã«è»¢éãããŠãŒã¶ãŒã¯ç®¡çãªããžã§ã¯ãã®ãã¹ãŠã®èŠçŽ ãæŽæ°ã§ããŸãã [ä¿å]ãã¯ãªãã¯ãããšãäžæã³ã³ããã¹ãå šäœãä¿åãããŸãã 圌ããã£ã³ã»ã«ãã¯ãªãã¯ãããšãäžæçãªã³ã³ããã¹ããšãšãã«å€æŽãç Žæ£ããããããäœãããå¿ èŠã¯ãããŸããã
ããªãã¯ãŸã ãã®ãã¹ãŠã®æ å ±ããããªãã®é ãå転ãããŸãããïŒ ããã§ãªãå Žåãããã«CoreDataãã«ãã³ã³ããã¹ãã«é¢ããæ²æé£è¡ããããŸãã
éåæããŒã¿ã¹ãã¬ãŒãž
Core Dataã®é人Marcus Zarraã¯ãåè¿°ã®Parent / Childã¡ãœããã«åºã¥ã次ã®ã¢ãããŒãã瀺ããŸãããããã£ã¹ã¯ãžã®æžã蟌ã¿å°çšã®ã³ã³ããã¹ããè¿œå ããŸãã åè¿°ã®ããã«ãé·ãæžã蟌ã¿æäœã¯ãUIãããªãŒãºããããšã«ãããã¡ã€ã³ã¹ã¬ãããçæéãããã¯ããå¯èœæ§ããããŸãã ãã®åççãªã¢ãããŒãã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ãèšé²ã¯å¥ã®ãã¥ãŒã«å²ãåœãŠããããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã¯ã¹ã ãŒãºãªæäœãç¶æããŸãïŒã¹ã ãŒãºãªãŸãŸã§ããããªãŒãºãããŸããïŒã
CoreDataã®ã»ããã¢ãããéåžžã«ç°¡åã§ãã å¿ èŠãªããšã¯ãpersistentStoreCoordinatorãæ°ããé衚瀺ã³ã³ããã¹ãã«ç§»åããã¡ã€ã³ã³ã³ããã¹ããåã«ããããšã ãã§ãã
// create writer MOC _privateWriterContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; [_privateWriterContext setPersistentStoreCoordinator:_persistentStoreCoordinator]; // create main thread MOC _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; _managedObjectContext.parentContext = _privateWriterContext;
ããã§ãæŽæ°ããšã«3ã€ã®ç°ãªãä¿åãè¡ãå¿ èŠããããŸããäžæã³ã³ããã¹ããã¡ã€ã³UIã³ã³ããã¹ããããã³ãã£ã¹ã¯ãžã®æžã蟌ã¿ã§ãã ãããã以åãšåãããã«ç°¡åã«performBlocksã¹ã¿ãã¯ãå®è£ ã§ããŸã...é·æéã®ããŒã¿ããŒã¹æäœïŒããšãã°ãå€æ°ã®ã¬ã³ãŒãã®ã€ã³ããŒãïŒããã£ã¹ã¯ãžã®æžã蟌ã¿ã®å ŽåããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã¯ããã¯è§£é€ããããŸãŸã§ãã
ãããã«
iOS 5ã§ã¯ãããã¯ã°ã©ãŠã³ããã¥ãŒã§ã®CoreDataã®äœæ¥ãå€§å¹ ã«ç°¡çŽ åãããåã³ã³ããã¹ããã芪ãžã®å€æŽãåãåããŸããã ãŸã iOS 3/4ã䜿çšããŠããå Žåããããã®æ©èœã¯ãã¹ãŠäœ¿çšã§ããŸããã ãã ããiOS 5ãæå°èŠä»¶ãšããæ°ãããããžã§ã¯ããéå§ããå Žåã¯ãäžèšã®ããã«ãMarcus Sarahã®Turbo Approachãããã«äœæã§ããŸãã
ã¶ãã¯ã»ãŠã©ã«ããŠã¹ããŒã¯ãããã¬ãŒã³ããŒã·ã§ã³ã®èŠèŠåã®ç·šéãã«é ãã¿ã€ãã®ãã¥ãŒäžŠè¡æ§ã䜿çšããããšã¯åé·ãããããªããšç§ã«ææããŸããã åã³ã³ããã¹ãã®ãã¥ãŒãã¬ã³ããªã³ã°ãã代ããã«NSContainmentConcurrencyTypeã䜿çšããå ŽåãperformBlockã©ãããŒãå®è¡ããå¿ èŠã¯ãããŸããã å¿ èŠãªã®ã¯ãä¿åããmainMOCã®performBlockã ãã§ãã
åæå®è¡æ§å¶çŽã®ã¿ã€ãã¯ãã³ã³ããã¹ããå®è¡ãããå€ãæ¹æ³ãã§ãããããã¯ããããäŒçµ±çã§ãã£ãããšãæå³ããŸããã ã³ã³ããã¹ãæäœãèªå·±ç®¡çã¹ã¬ããã¢ãã«ã«åçŽã«ãã€ã³ãããŸãã æ°ããã³ã³ãããŒã©ãŒããšã®æœåšçãªãã¥ãŒã®é©åœã®ã»ããã¯ãç¡é§ã§ãäžå¿ èŠã§ãé ãã§ãã
NSManagedObjectContextã¯ã€ã³ããªãžã§ã³ãã«ä¿åããã³ããŒãžããæ¹æ³ãç¥ã£ãŠãããããã¹ããªãŒã ã®ã¡ã€ã³ã³ã³ããã¹ãã¯ã¡ã€ã³ã¹ããªãŒã ã«çµã³ä»ãããããã®ããŒãžã¯åžžã«å®å šã«å®è¡ãããŸãã ãã¬ãŒã³ããŒã·ã§ã³ããžã¥ã¢ã©ã€ãŒãŒã·ã§ã³ã®ç·šéã¯ãã¡ã€ã³ãã¬ãŒã³ããŒã·ã§ã³ããžã¥ã¢ã©ã€ãŒãŒã·ã§ã³ãšåãæ¹æ³ã§ã¡ã€ã³ã¹ããªãŒã ã«é¢é£ä»ããããŸãã å¯äžã®æ¹æ³ã¯ãUIã§ã®ã¿è¡ãããåå¥ã®æäœã§ãããããããã§å¶éã®äžŠååŠçã䜿çšããã®ã«é©ããŠããŸãã ç·šéã³ã³ããã¹ãã¯æŠå¿µçã«ã¯ãæ°ããããã®ã§ã¯ãªããå€æŽãå®å šã«å ã«æ»ããªãããå€æŽãåŸãŸã§å»¶æããã ãã§ãã
ãããã£ãŠãå®éã«ã¯å人ã®å¥œã¿ã«äŸåããŸããperformBlockã䜿çšããããåæå®è¡å¶éã®ãªãé ããã¥ãŒã§ãã ç§ã«é¢ããŠã¯ããããã䜿çšããããšã§åŸãããã»ãã¥ãªãã£ã®ããã«ãç§ã¯é ããããã¥ãŒã奜ãããã«ããŸãã
pså€ãã®äººã«ãšã£ãŠããã®èšäºã¯åœ¹ã«ç«ããªããšæããããããããŸãããããã®èšäºããäœã圹ã«ç«ã€ãã®ãåºãŠããããšãé¡ã£ãŠããŸãã ã³ã¡ã³ããããå Žåã¯ã翻蚳ãããŸãscããªãã§ãå人çã«æžããŠãä¿®æ£ããŠãã ãã:)