iOS5 NewStuff
Upcoming SlideShare
Loading in...5
×
 

iOS5 NewStuff

on

  • 1,457 views

'Development using iOS5 NewStuff' keynote for #IDOC2012. Bandung, 18th February 2012.

'Development using iOS5 NewStuff' keynote for #IDOC2012. Bandung, 18th February 2012.
- iCloud Storage
- CoreImage
- NewsStand
Demo and sample code : https://github.com/DeenNa

Statistics

Views

Total Views
1,457
Views on SlideShare
1,030
Embed Views
427

Actions

Likes
0
Downloads
13
Comments
0

2 Embeds 427

http://www.id-objectivec.org 426
http://www.verious.com 1

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

iOS5 NewStuff iOS5 NewStuff Presentation Transcript

  • iOS 5 New Stuff R.Ayu Maulidina.I.
  • Over 200 new user features
  • SDK & Development tools?over 1,500 new APIs and powerful new development tools
  • iCloud Storage API Apa itu iCloud? - Sync service - Transfers user data between devices - Runs in background - Per-app sandboxing (as usual) Keuntungannya Apa ?- Gak perlu ‘sync server’ sendiri.- Gak perlu ‘network protocol’ sendiri.- Gak perlu bayar ‘storage/bandwidth’ sendiri. Intinya sih gak perlu repot-repot.
  • Konsep dan Ketentuan iCloud UbiquitousSuatu keadaan yang memungkinkan manusia untuk berinteraksi dengan ‘komputer’ dimana saja, kapan saja dan bagaimana saja.
  • Sinkronisasi BackgroundUbiquity daemon, ubdSaat anda menyimpan perubahan, ubd mengirimkannya pada ‘cloud’ubd akan mengunduhnya dari iCloudDimana itu berarti....
  • Data anda dapat berubah tanpa peringatan..
  • iCloud ContainersLokasi untuk data aplikasi anda berada di iCloudSetiap pengaktifan iCloud pada aplikasi setidaknya hanyamemiliki satu tempat.Kontainer sesuai dengan direktori yang kita buat
  • File CoordinatorData dapat diubah oleh aplikasi anda atau oleh ubd(Ubiquity Daemon)Membutuhkan ‘reader/writer lock’ untuk akses koordinasiMenggunakan ‘NSFileCoordinator’ saat menulis ataumembacanya
  • File PresenterDisertakan juga pada file koordinatorMenerapkan ‘NSFilePresenter’ agar mendapatpemberitahuan akan adanya perubahanSaat file koordinator membuat perubahan, maka ‘filepresenter’ ini akan dipanggil.
  • iCloud APIsKey-value storeCore DataDocument
  • Gimana cara mengaktifkan iCloud ?App ID on Provisioning Portal --->developer.apple.com/ios/ ---> app IDs
  • Konfigurasi app ID
  • Peringatan!
  • Configuration name for identifier, entitlements file, iCloud key-value store, containers and keychain access groups.
  • Entitlements Setting
  • Ubiquitous Documents
  • UIDocumentAsynchronous block-based reading and writingAuto-savingFlat file and file packages
  • UIDocument with iCloudActs as a file coordinator and presenterMendeteksi conflicts- Notifications- API to help resolve
  • UIDocument Concepts Outside the (sand)box- iCloud documents are not located in your app sandbox- Located in your iCloud container- Create the document in the sandbox- Move it to iCloud
  • Document StateUIDocumentStateNormalUIDocumentStateClosedUIDocumentStateInConflictUIDocumentStateSavingErrorUIDocumentStateEditingDisabledUIDocumentStateChangedNotification
  • Demo Code: CloudNotes
  • Subclassing UIDocument@interface NoteDocument : UIDocument@property (strong, readwrite) NSString *documentText;@end
  • Subclassing UIDocument- (BOOL)loadFromContents:(id)contents ofType:(NSString*)typeName error:(NSError *__autoreleasing *)outError;- (id)contentsForType:(NSString *)typeName error:(NSError*__autoreleasing *)outError;
  • - (BOOL)loadFromContents:(id)contents ofType:(NSString*)typeName error:(NSError *__autoreleasing *)outError{ NSString *text = nil; if ([contents length] > 0) { text = [[NSString alloc] initWithBytes:[contents bytes] length:[contents length] encoding:NSUTF8StringEncoding]; } else { text = @""; }}[self setDocumentText:text];return YES;
  • - (id)contentsForType:(NSString *)typeName error:(NSError*__autoreleasing *)outError { if ([[self documentText] length] == 0) { [self setDocumentText:@"New note"]; } return [NSData dataWithBytes:[[self documentText] UTF8String] length:[[self documentText] length]];}
  • Creating a NoteDocument
  • - (NSURL*)ubiquitousDocumentsDirectoryURL{ NSURL *ubiquitousContainerURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; NSURL *ubiquitousDocumentsURL = [ubiquitousContainerURL URLByAppendingPathComponent:@"Documents"]; if (ubiquitousDocumentsURL != nil) { if (![[NSFileManager defaultManager] fileExistsAtPath:[ubiquitousDocumentsURL path]]) { NSError *createDirectoryError = nil; BOOL created = [[NSFileManager defaultManager] createDirectoryAtURL:ubiquitousDocumentsURL withIntermediateDirectories:YES attributes:0 error:&createDirectoryError]; if (!created) { NSLog(@"Error creating directory at %@: %@", ubiquitousDocumentsURL, createDirectoryError); } } } else { NSLog(@"Error getting ubiquitous container URL"); } return ubiquitousDocumentsURL;}
  • - (NSURL*)ubiquitousDocumentsDirectoryURL{ NSURL *ubiquitousContainerURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; NSURL *ubiquitousDocumentsURL = [ubiquitousContainerURL URLByAppendingPathComponent:@"Documents"]; if (ubiquitousDocumentsURL != nil) { if (![[NSFileManager defaultManager] fileExistsAtPath:[ubiquitousDocumentsURL path]]) { NSError *createDirectoryError = nil; BOOL created = [[NSFileManager defaultManager] createDirectoryAtURL:ubiquitousDocumentsURL withIntermediateDirectories:YES attributes:0 error:&createDirectoryError]; if (!created) { NSLog(@"Error creating directory at %@: %@", ubiquitousDocumentsURL, createDirectoryError); } } } else { NSLog(@"Error getting ubiquitous container URL"); } return ubiquitousDocumentsURL;}
  • - (void)createFileNamed:(NSString *)filename{ NSURL *localFileURL = [[self localDocumentsDirectoryURL] URLByAppendingPathComponent:filename]; NoteDocument *newDocument = [[NoteDocument alloc] initWithFileURL:localFileURL]; [newDocument saveToURL:localFileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { if (success) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSURL *destinationURL = [[self ubiquitousDocumentsDirectoryURL] URLByAppendingPathComponent:filename]; NSError *moveToCloudError = nil; BOOL success = [[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:[newDocument fileURL] destinationURL:destinationURL error:&moveToCloudError]; if (!success) { NSLog(@"Error moving to iCloud: %@", moveToCloudError); } }); } }];}
  • - (void)createFileNamed:(NSString *)filename{ NSURL *localFileURL = [[self localDocumentsDirectoryURL] URLByAppendingPathComponent:filename]; NoteDocument *newDocument = [[NoteDocument alloc] initWithFileURL:localFileURL]; [newDocument saveToURL:localFileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { if (success) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSURL *destinationURL = [[self ubiquitousDocumentsDirectoryURL] URLByAppendingPathComponent:filename]; NSError *moveToCloudError = nil; BOOL success = [[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:[newDocument fileURL] destinationURL:destinationURL error:&moveToCloudError]; if (!success) { NSLog(@"Error moving to iCloud: %@", moveToCloudError); } }); } }];}
  • - (void)createFileNamed:(NSString *)filename{ NSURL *localFileURL = [[self localDocumentsDirectoryURL] URLByAppendingPathComponent:filename]; NoteDocument *newDocument = [[NoteDocument alloc] initWithFileURL:localFileURL]; [newDocument saveToURL:localFileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { if (success) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSURL *destinationURL = [[self ubiquitousDocumentsDirectoryURL] URLByAppendingPathComponent:filename]; NSError *moveToCloudError = nil; BOOL success = [[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:[newDocument fileURL] destinationURL:destinationURL error:&moveToCloudError]; if (!success) { NSLog(@"Error moving to iCloud: %@", moveToCloudError); } }); } }];}
  • Create new document
  • Core Image
  • image processing technologymemungkinkan proses mendekati real-timemenyediakan akses untuk ‘built-in image filters’ padavideo and gambarmenyediakan juga fitur untuk membuat ‘custom filters’
  • Class References1.CIColor2.CIContext3.CIDetector4.CIFaceFeature5.CIFeature6.CIFilter7.CIImage8.CIVector
  • Face Detection
  • CIFaceFeature Facial Features•   hasLeftEyePosition  property•   hasRightEyePosition  property•   hasMouthPosition  property•   leftEyePosition  property•   rightEyePosition  property•   mouthPosition  property
  • Demo Code: Easy Face Detection
  • // well iterate through every detected face. CIFaceFeature provides us // with the width for the entire face, and the coordinates of each eye // and the mouth if detected. Also provided are BOOLs for the eyes and // mouth so we can check if they already exist. for(CIFaceFeature* faceFeature in features) { // get the width of the face CGFloat faceWidth = faceFeature.bounds.size.width; // create a UIView using the bounds of the face UIView* faceView = [[UIView alloc] initWithFrame:faceFeature.bounds]; // add a border around the newly created UIView faceView.layer.borderWidth = 1; faceView.layer.borderColor = [[UIColor redColor] CGColor]; // add the new view to create a box around the face [self.window addSubview:faceView]; if(faceFeature.hasLeftEyePosition) { // create a UIView with a size based on the width of the face UIView* leftEyeView = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.leftEyePosition.x-faceWidth*0.15,faceFeature.leftEyePosition.y-faceWidth*0.15, faceWidth*0.3, faceWidth*0.3)]; // change the background color of the eye view [leftEyeView setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]]; // set the position of the leftEyeView based on the face [leftEyeView setCenter:faceFeature.leftEyePosition]; // round the corners leftEyeView.layer.cornerRadius = faceWidth*0.15; // add the view to the window [self.window addSubview:leftEyeView]; } if(faceFeature.hasRightEyePosition) { // create a UIView with a size based on the width of the face UIView* leftEye = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.rightEyePosition.x-faceWidth*0.15,faceFeature.rightEyePosition.y-faceWidth*0.15, faceWidth*0.3, faceWidth*0.3)]; // change the background color of the eye view [leftEye setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]]; // set the position of the rightEyeView based on the face [leftEye setCenter:faceFeature.rightEyePosition]; // round the corners leftEye.layer.cornerRadius = faceWidth*0.15; // add the new view to the window [self.window addSubview:leftEye]; }
  • Detector Option KeysKeys used in the options dictionary to configure a detector.Detector Accuracy OptionsNSString* const CIDetectorAccuracyLow;NSString* const CIDetectorAccuracyHigh;- CIDetectorAccuracyLowIndicates that the detector should choose techniques that are lower in accuracy, but can beprocessed more quickly.- CIDetectorAccuracyHighIndicates that the detector should choose techniques that are higher in accuracy, even if itrequires more processing time.
  • Real-time Example by Erica Sadun
  • Newsstand
  • Newsstand for developerSimpel dan mudah digunakan untuk konten majalahdan surat kabarTermasuk gratis berlangganan untuk pengguna iPhone,iPod touch dan iPadMenerbitkan edisi terbaru majalah dan surat kabarlangsung menggunakan Newsstand kit dan Store kitframework
  • NewsstandKitPush notificationupdatesContent organizationBackgrounddownloads
  • Menampilkan pada NewsstandMenjadikan Newsstand app Menambahkan satu key dalam file Info.plist <key>UINewsstandApp</key> <true/> Yak jadilah Newsstand app! Tapi masih butuh icon nih.
  • Menampilkan pada NewsstandStandard icon specification Standard icon specification • Top-level key in your Info.plist with an array of image name <key>CFBundleIconFiles</key> Key pada level paling atas di file <array> Info.plist berisi array nama dari image ! <string>Icon.png</string> ! <string>Icon@2x.png</string> ... </array>
  • Menampilkan pada NewsstandUpdating your Info.plist Updating your Info.plist <key>CFBundleIcons</key> New top-level key <dict> <key>CFBundlePrimaryIcon</key> Icon style key <dict> <key>CFBundleIconFiles</key> <array> Existing CFBundleIconFiles <string>Icon.png</string> <string>Icon@2x.png</string> </array> </dict> </dict>
  • Newsstand info-plist
  • Handling UpdatesRetrieving and presenting content Retrieving and presenting content Informing theInforming the app • app INFORMING • Organizing issues Organizing issues content • Downloading UPDATING ORGANIZING • Updating your icon Downloading content DOWNLOADING Updating your icon 27
  • Informing the AppPush notifications
  • Informing the AppNewsstand Push Notifications
  • Informing the AppNewsstand Push Notifications
  • Organizing IssuesUsing NKLibrary • Provides persistent state for : ■ Available issues ■ Ongoing downloads ■ Issue being read!• Organizes issues ■ Uses app’s Caches directory ■ Improves resource management
  • Organizing IssuesNKIssues • Creating issues ■ Penamaan yang unik ■ Tanggal publikasi NKIssue *myIssue = [myLibrary addIssueWithName:issueName date:issueDate]; ■ Mengolah repository di dalam ‘library’ NSURL *baseURL = [myIssue contentURL];• Setting the current issue[myLibrary setCurrentlyReadingIssue:myIssue];
  • Handling UpdatesDownloading contentDownloading ContentNKAssetDownload • Handles data transfer ■ Keeps going• Uses NSURLConnectionDelegate• Wake for critical events newsstand-content• Wi-Fi only in background
  • Downloading ContentSetup NSArray *itemsToDownload = !! query server for list of assets for (item in itemsToDownload) { NSURLRequest *downloadRequest = [item URLRequest]; NKAssetDownload *asset = [issue addAssetWithRequest:downloadRequest]; NSURLConnection *connection = [asset downloadWithDelegate:myDelegate]; }}
  • Downloading ContentNSURLConnectionDownloadDelegate [asset downloadWithDelegate:myDelegate];• Implements NSURLConnectionDelegate ■ Status ■ Authentication ■ Completion• Modifications-connection:didWriteData:totalBytesWritten:expectedTotalBytesWritten:-connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytesWritten:-connectionDidFinishDownloading:destinationURL: ---> required
  • Updating Your Newsstand Icon Update your icon and badge Simple! Update Icon-[UIApplication setNewsstandIconImage:(UIImage*)]• Bisa digunakan saat berjalan di background, jadi bisa diupdate kapanpun jika konten sudah siap. Update Badge• Uses existing badge API-[UIApplication setApplicationIconBadgeNumber:(NSInteger)]
  • DemoCreating a Newsstand App
  • See you...