iCloud                Mick Kubo(@komarineko)                    http://komarineko.net/                      2012    1   21...
•   iCloud                                            ...                                              ....              •...
iCloud                   •                 (                           )                   •                 (            ...
•   iCloud                                                iCloud              •            daemon ”ubd”              •    ...
• NSFilePresenter              • NSFileCoordinator              •              •          UIDocument12   2   14
UIDocument              • NSFilePresenter              •                 UIDocument                loadFromContents:ofType...
UIDocument              • delegate                   (→View    )              • View                      →              •...
• iCloud                defaultFileManager ( [NSFileManager defaultManager] )                URLForUbiquityContainerIdenti...
•   NSMetadataQuery                        )                  	       NSMetadataQuery *query = [[NSMetadataQuery alloc] in...
•                  saveToURL:forSaveOperation:completionHandler:                  	   forSaveOperation UIDocumentSaveForCr...
• iCloud                                (                  defaultFileManager ( [NSFileManager defaultManager] )          ...
• iCloud                setUbiquitous:itemAtURL:destinationURL:error:                                                     ...
•              •12   2   14
Upcoming SlideShare
Loading in …5
×

20120121

1,623 views

Published on

NSEG 第23回勉強会での発表で使用したスライドです。

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

20120121

  1. 1. iCloud Mick Kubo(@komarineko) http://komarineko.net/ 2012 1 2112 2 14
  2. 2. • iCloud ... .... • NSDocument ... ... Web ...( ) • ...12 2 14
  3. 3. iCloud • ( ) • ( ) • Apple ... • ... Google Evernote • WWDC2011 iCloud Windows API ...12 2 14
  4. 4. • iCloud iCloud • daemon ”ubd” • • iCloud “ubd” (ry12 2 14
  5. 5. • NSFilePresenter • NSFileCoordinator • • UIDocument12 2 14
  6. 6. UIDocument • NSFilePresenter • UIDocument loadFromContents:ofType:error: ( ) contentsForType:error: ( ) (ViewController) delegate12 2 14
  7. 7. UIDocument • delegate (→View ) • View → •UIDocumentStateChangedNotification [NSNotificationCenter defaultCenter] documentState UIDocumentStateNormal : UIDocumentStateInConflict : UIDocumentStateSavingError UIDocumentStateNormal12 2 14
  8. 8. • iCloud defaultFileManager ( [NSFileManager defaultManager] ) URLForUbiquityContainerIdentifier: →iCloud nil iCloud iCloud iCloud12 2 14
  9. 9. • NSMetadataQuery ) NSMetadataQuery *query = [[NSMetadataQuery alloc] init]; query.predicate = [NSPredicate predicateWithFormat:@"%K ENDSWITH .txt", NSMetadataItemFSNameKey]; query.searchScopes = [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateUbiquitousDocuments:) name:NSMetadataQueryDidFinishGatheringNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateUbiquitousDocuments:) name:NSMetadataQueryDidUpdateNotification object:nil]; [query startQuery];12 2 14
  10. 10. • saveToURL:forSaveOperation:completionHandler: forSaveOperation UIDocumentSaveForCreating • openWithCompletionHandler: • closeWithCompletionHandler: ( )12 2 14
  11. 11. • iCloud ( defaultFileManager ( [NSFileManager defaultManager] ) ) setUbiquitous:itemAtURL:destinationURL:error: → iCloud setUbiquitous YES iCloud → setUbiquitous NO • defaultFileManager ( [NSFileManager defaultManager] ) removeItemAtURL:error:12 2 14
  12. 12. • iCloud setUbiquitous:itemAtURL:destinationURL:error: ( ) NSFilePresenter )( iOS ) dispatch_queue_t q_default; q_default = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(q_default, ^(void) { NSFileManager *fileManager = [[NSFileManager alloc] init]; NSError *error = nil; BOOL success = [fileManager setUbiquitous:YES itemAtURL:sourceURL destinationURL:destinationURL error:&error]; dispatch_queue_t q_main = dispatch_get_main_queue(); dispatch_async(q_main, ^(void) { if (success) { FileRepresentation *fileRepresentation = [[FileRepresentation alloc] initWithFileName:fileToMove.fileName url:destinationURL]; [_fileList removeObject:fileToMove]; [_fileList addObject:fileRepresentation]; NSLog(@"moved file to cloud: %@", fileRepresentation); } if (!success) { NSLog(@"Couldnt move file to iCloud: %@", fileToMove); } }); });12 2 14
  13. 13. • •12 2 14

×