{"id":191868,"date":"2013-08-29T12:52:03","date_gmt":"2013-08-29T08:52:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=191868"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=191868","title":{"rendered":"<span class=\"post_title\">\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GCD<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u043e\u0434 iOS \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c iTunes File Sharing \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 Info.plist: <\/p>\n<pre><code class=\"cpp\">UIFileSharingEnabled = YES<\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0434\u0435\u043b\u0430. \u0421\u043e\u043b\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u043f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0441\u0442\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 Documents \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/fa0\/61a\/bb1\/fa061abb1253145d63482602dbae9dfd.png\" alt=\"image\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0438\u0437 Concurrency Programming Guide. \u0412 GCD \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043a\u0430\u043a <b>dispatch source<\/b> \u2013 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0442\u0447\u0430\u0435\u0442 \u0437\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0446\u0438\u044e \u043e\u0431\u0440\u043e\u0431\u043e\u0442\u043a\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u0430\u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u043a <b>descriptor sources<\/b>, \u043e\u043f\u043e\u0432\u0435\u0449\u0430\u044e\u0449\u0438\u0439 \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438\u043b\u0438 \u0441\u043e\u043a\u0435\u0442\u0430\u043c\u0438. <\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>dispatch_source_create<\/code> \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0444\u0430\u0439\u043b\u043e\u0432 (directory file descriptor), \u0430 \u043f\u043e \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044e (\u0437\u0430\u043f\u0438\u0441\u044c \u0444\u0430\u0439\u043b\u0430) \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0431\u043b\u043e\u043a \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0431\u043b\u0438\u0436\u0435 \u043a \u0442\u0435\u043b\u0443. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 <code>startMonitor<\/code> \u0438 <code>stopMonitor<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0445 \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u044e\u0432\u0430\u044e\u0449\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0443\u0436\u043d\u043e\u0439 \u043d\u0430\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0443-\u0442\u0440\u043e\u0439\u043a\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 handler block.<\/p>\n<pre><code class=\"cpp\"> - (void)startMonitor { \t\/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043b\u0438 \u0443\u0436\u0435 dispatch_source_t \tif (_src != NULL) return;       \t\/\/ \u043f\u0443\u0442\u044c \u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 Documents \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435     NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];      \t\/\/ \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0444\u0430\u0439\u043b\u043e\u0432, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (O_EVTONLY) \t_fileDescriptor = open([docPath fileSystemRepresentation], O_EVTONLY);      \t\/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 thread, \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c UI \tdispatch_queue_t queue = dispatch_get_main_queue();      \t\/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 dispatch source \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (write) \t_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, _fileDescriptor, DISPATCH_VNODE_WRITE,  queue);\t      \t\/\/ handler block \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \tdispatch_source_set_event_handler(_src, ^{         [self directoryDidChange];     });      \t\/\/ \u043f\u0440\u0438 \u043e\u0442\u043c\u0435\u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \tdispatch_source_set_cancel_handler(_src, ^{       close(_fileDescriptor);    });      \tdispatch_resume(_src); }  - (void)stopMonitor { \tif (_src) { \/\/ \u0442\u0443\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u043b\u043e\u043c\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \t\tdispatch_source_cancel(_src); \t\t_src = NULL; \t} }  - (void)directoryDidChange {     if(!waitingForDocumentsDirectoryTimeout) {         waitingForDocumentsDirectoryTimeout = YES; \/\/ \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0444\u043b\u0430\u0433 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f         _lastDocumentsDirectoryReferenceArray=[self documentsDirectoryReferenceArray]; \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \/\/...\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u043b\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c \u0432 \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440         [self performSelector:@selector(checkForDocumentsDirectoryChanges) withObject:nil afterDelay:1.0 inModes:[NSArray arrayWithObjects:NSRunLoopCommonModes,nil]];     } }  -(void)checkForDocumentsDirectoryChanges{     NSArray *newDocumentsDirectoryReferenceArray=[self documentsDirectoryReferenceArray];     \/\/ \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432     if(![newDocumentsDirectoryReferenceArray isEqualToArray:_lastDocumentsDirectoryReferenceArray]) {       \/\/ \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u043e\u043c         _lastDocumentsDirectoryReferenceArray=newDocumentsDirectoryReferenceArray;         [self performSelector:@selector(checkForDocumentsDirectoryChanges) withObject:nil afterDelay:1.0 inModes:[NSArray arrayWithObjects:NSRunLoopCommonModes,nil]];     } else {         \/\/ \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430         waitingForDocumentsDirectoryTimeout=NO;         _lastDocumentsDirectoryReferenceArray=nil;        \/\/ ...\u0442\u0443\u0442 \u0443\u0436 \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448 \u0431\u043b\u043e\u043a \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440       [self scanDocumentsDerectory];     } }  -(NSArray *)documentsDirectoryReferenceArray {     \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435-\u0420\u0430\u0437\u043c\u0435\u0440     NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];     NSArray *documentsDirectoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectoryPath error:NULL];          NSMutableArray *documentsDirectoryReferenceArray=[NSMutableArray arrayWithCapacity:10];          for(NSString *fileName in documentsDirectoryContents){                  NSString *filePath=[documentsDirectoryPath stringByAppendingPathComponent:fileName];                  NSError *error;         NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&error];         NSInteger fileSize = [[fileAttributes objectForKey:NSFileSize] intValue];         NSString *fileWithLength=[NSString stringWithFormat:@&quot;%@-%d&quot;,fileName,fileSize];                  [documentsDirectoryReferenceArray addObject:fileWithLength];     }          return documentsDirectoryReferenceArray; } <\/code><\/pre>\n<p>  \u041d\u0443, \u0430 \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u043b\u0441\u044f \u0433\u043b\u0430\u0437\u0430\u043c\u0438 \u043f\u043e \u0442\u0435\u043a\u0442\u0441\u0443 \u0438 \u043a\u043e\u043c\u0443 \u043b\u0435\u043d\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 <a href=\"https:\/\/github.com\/Cocoanetics\/DTFoundation\">Cocoanetics\/DTFoundation<\/a> \u043a\u043b\u0430\u0441\u0441 <code>DTFolderMonitor<\/code>. <\/p>\n<p>  \u0415\u0449\u0435, \u0438\u0437 \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 <a href=\"http:\/\/pdfboxapp.com\">\u0441\u0432\u043e\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c<\/a>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u043c iTunes File Sharing, \u0445\u043e\u0447\u0443 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0442\u0438\u043f\u0430 <code>scanDocumentDerectory<\/code>, \u043f\u043e\u043c\u0438\u043c\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c. \u0415\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043d\u043e \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0444\u0430\u0439\u043b\u0430\u0445 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441 \u0438\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 iTunes \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0431\u044d\u043a\u0433\u0440\u0430\u0443\u043d\u0434\u0435, \u043b\u0438\u0431\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e.<\/p>\n<pre><code class=\"cpp\"> - (void)applicationWillEnterForeground:(UIApplication *)application {     [self scanDocumentsDirectory]; }<\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\"><a href=\"https:\/\/devforums.apple.com\/thread\/44497?start=0&amp;tstart=0\">\u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0435\u0442\u043a\u0430 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u043e \u0442\u0435\u043c\u0435 \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 Apple<\/a> (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u0435\u0432\u0435\u043b\u043e\u043f\u0435\u0440\u0441\u043a\u0438\u0439 \u0430\u043a\u0430\u0443\u043d\u0442 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430)<br \/>  <a href=\"http:\/\/www.mlsite.net\/blog\/?p=2312\">Directory Monitor<\/a> \u2013 \u043e\u043b\u0434\u0441\u043a\u0443\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u043e\u0442 Michael Heyeck<br \/>  <a href=\"http:\/\/www.mlsite.net\/blog\/?p=2655\">Directory Monitoring and GCD<\/a> \u043e\u043d \u0436\u0435, \u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439<br \/>  <a href=\"https:\/\/www.cocoanetics.com\/2013\/08\/monitoring-a-folder-with-gcd\/\">Monitoring a Folder with GCD<\/a> \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 \u0421ocoanetics  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/191868\/\"> http:\/\/habrahabr.ru\/post\/191868\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u043e\u0434 iOS \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c iTunes File Sharing \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 Info.plist: <\/p>\n<pre><code class=\"cpp\">UIFileSharingEnabled = YES<\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0434\u0435\u043b\u0430. \u0421\u043e\u043b\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u043f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0441\u0442\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 Documents \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/fa0\/61a\/bb1\/fa061abb1253145d63482602dbae9dfd.png\" alt=\"image\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-191868","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/191868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191868"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/191868\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}