SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Downloaden Sie, um offline zu lesen
What’s new in iOS 7?
Highlights of 1500 new APIs

Jordi Gimenez (@gimix3) & Hermes Pique (@hpique)
NSBarcelona
82% of devices are using iOS 7.

As measured by the App Store during a 7-day period ending February 23, 2014.
Agenda
What we will cover
•
•
•
•
•
•
•

NSTextStorage
UIViewController transitions
iCloud & Core Data
App Store Receipt
Speech Synthesis
JavaScript Evaluation
New Networking Possibilities
NSTextStorage
Text Kit
UILabel

UITextView

Text Kit

Core Text

Core Graphics

UITextField
Text Kit
Classes

NSTextStorage

NSLayoutManager

NSTextContainer

What?

How?

Where?

(text & attributes)

(glyphs & location)

(areas)
Text Kit
Use defaults or provide your own classes

textStorage = [NSTextStorage new];
layoutManager = [NSLayoutManager new];
textContainer = [[NSTextContainer alloc] initWithSize:size];
[layoutManager addTextContainer:textContainer];
[textStorage addLayoutManager:layoutManager];
!

textView = [[UITextView alloc] initWithFrame:frame
textContainer:textContainer];
Text Kit
NSTextStorage
• NSMutableAttributedString subclass

• Subclass to provide custom editing
- (void)processEditing
{
[_backingStore beginEditing];
// Custom editing
[_backingStore endEditing];
[super processEditing];
}
Text Kit
Using images in NSTextStorage
(void)replaceLettersInRange:(NSRange)range
{
[backingStore.string enumerateSubstringsInRange:range
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *substring, NSRange substringRange,
NSRange enclosingRange, BOOL *stop)
{
!

NSTextAttachment *textAttachment = [NSTextAttachment new];
textAttachment.image = [self imageForString:substring];
NSAttributedString *attributed = [NSAttributedString
attributedStringWithAttachment:textAttachment];
[backingStore replaceCharactersInRange:substringRange
withAttributedString:attributed];
!

}];
}
Demo

github.com/NSBarcelona/CandyCrushKeyboard
UIViewController Transitions
UIViewController Transitions
Customizable transitions
•
•
•
•

Presentations and dismissals
UINavigationController
UITabBarController
UICollectionViewController layout-to-layout
UIViewController Transitions
The container view

Container view
UIViewController A

UIViewController B

View A

View B
UIViewController Transitions
Returning the transition animation

- (id <UIViewControllerAnimatedTransitioning>)navigationController:
(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
id<UIViewControllerAnimatedTransitioning> animator = [MyAnimationController new];
return animator;
}
UIViewController Transitions
Animating the transition
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)context {
!

UIViewController *fromVC = [context
viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [context
viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *container = context.containerView;
[container insertSubview:toViewController.view aboveSubview:fromViewController.view];
!

// Prepare for animation
!

NSTimeInterval duration = [self transitionDuration:context];
[UIView animateWithDuration:duration animations:^{
// Animations
} completion:^(BOOL finished) {
// Cleanup and restore state
[context completeTransition:YES];
}];
}
Demo

github.com/NSBarcelona/Transictures
Adding iCloud to Core Data
“…the average [US] household has 1.6 Apple devices.”

–CNBC in 2012
iCloud
• Using iCloud in iOS 5-6 is a bug
• Sync network setup (!)
• Limited APIs
• Poor support for account changes
• Unreliability
• In iOS 7 it’s actually usable
iCloud
Core Data with iCloud in 3 steps

1. Add iCloud to Core Data
2. Respond to changes
3. Respond to account changes
iCloud
Adding iCloud to Core Data

NSDictionary *options = @{ NSPersistentStoreUbiquitousContentNameKey : @"name" }
!

[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:url
options:options
error:&error];
iCloud
Responding to changes

NSPersistentStoreDidImportUbiquitousContentChangesNotification
!
!

[moc performBlockAndWait:^{
[moc mergeChangesFromContextDidSaveNotification:notification];
}];
iCloud
Responding to account changes
NSPersistentStoreCoordinatorStoresWillChangeNotification
!
!

dispatch_sync(dispatch_get_main_queue(), ^{
// Prepare UI
});
[moc performBlockAndWait:^{
NSError *error = nil;
if ([moc hasChanges]) {
[moc save:&error];
}
[moc reset];
}];
iCloud
Responding to account changes
NSPersistentStoreCoordinatorStoresDidChangeNotification
!
!

dispatch_sync(dispatch_get_main_queue(), ^{
// Update UI
});
Demo

github.com/NSBarcelona/CloudPhotos
The App Store Receipt
“This is doable.”

–James Wilson (Engineering Manager for the App Store in OS X) at WWDC 2013, about verifying the
App Store receipt
App Store Receipt
Verification in 5 steps
1.
2.
3.
4.
5.

Get the receipt data
Verify the receipt signature
Get the receipt fields
Verify the receipt hash
Get in-app purchases (optional)
App Store Receipt
Getting the receipt data
const char *cpath = [[path stringByStandardizingPath] fileSystemRepresentation];
FILE *fp = fopen(cpath, "rb");
if (!fp) return nil;
!

PKCS7 *p7 = d2i_PKCS7_fp(fp, NULL);
fclose(fp);
if (!p7) return nil;
!

NSURL *certificateURL = [[NSBundle mainBundle]
URLForResource:@"AppleIncRootCertificate" withExtension:@"cer"];
NSData *certificateData = [NSData dataWithContentsOfURL:certificateURL];
if ([self verifyPCKS7:p7 withCertificateData:certificateData]) {
struct pkcs7_st *contents = p7->d.sign->contents;
if (PKCS7_type_is_data(contents)) {
ASN1_OCTET_STRING *octets = contents->d.data;
data = [NSData dataWithBytes:octets->data length:octets->length];
}
}
PKCS7_free(p7);
App Store Receipt
Verifying the receipt signature
int result = 0;
OpenSSL_add_all_digests(); // Required for PKCS7_verify to work
X509_STORE *store = X509_STORE_new();
if (store) {
const uint8_t *certificateBytes = (uint8_t *)(certificateData.bytes);
X509 *certificate = d2i_X509(NULL, &certificateBytes
(long)certificateData.length);
if (certificate){
X509_STORE_add_cert(store, certificate);
BIO *payload = BIO_new(BIO_s_mem());
result = PKCS7_verify(container, NULL, store, NULL, payload, 0);
BIO_free(payload);
X509_free(certificate);
}
}
X509_STORE_free(store);
EVP_cleanup();
App Store Receipt
Getting the receipt fields
[RMAppReceipt enumerateASN1Attributes:asn1Data.bytes length:asn1Data.length
usingBlock:^(NSData *data, int type) {
const uint8_t *s = data.bytes; const NSUInteger length = data.length;
switch (type) {
case 2: bundleIdData = data; _bundleId = RMASN1ReadUTF8String(&s, length); break;
case 3: appVersion = RMASN1ReadUTF8String(&s, length); break;
case 4: opaqueValue = data; break;
case 5: hash = data; break;
case 17: {
RMAppReceiptIAP *purchase = [[RMAppReceiptIAP alloc] initWithASN1Data:data];
[purchases addObject:purchase];
break; }
case 19: originalAppVersion = RMASN1ReadUTF8String(&s, length); break;
case 21: expirationDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&s,
length)]; break;
}
}];
App Store Receipt
Verifying the receipt hash
NSUUID *uuid = [[UIDevice currentDevice] identifierForVendor];
unsigned char uuidBytes[16];
[uuid getUUIDBytes:uuidBytes];
!

NSMutableData *data = [NSMutableData data];
[data appendBytes:uuidBytes length:sizeof(uuidBytes)];
[data appendData:opaqueValue];
[data appendData:bundleIdData];
!

NSMutableData *expectedHash = [NSMutableData dataWithLength:SHA_DIGEST_LENGTH];
SHA1(data.bytes, data.length, expectedHash.mutableBytes);
!

BOOL verified = [expectedHash isEqualToData:hash];
App Store Receipt
Getting the in-app purchases
[RMAppReceipt enumerateASN1Attributes:asn1Data.bytes length:asn1Data.length usingBlock:^(NSData
*data, int type) {
const uint8_t *p = data.bytes; const NSUInteger length = data.length;
switch (type) {
case 1701: quantity = RMASN1ReadInteger(&p, length); break;
case 1702: productId = RMASN1ReadUTF8String(&p, length); break;
case 1703: transactionIdentifier = RMASN1ReadUTF8String(&p, length); break;
case 1704: purchaseDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&p,
length)];
case 1705: originalTransactionId = RMASN1ReadUTF8String(&p, length); break;
case 1706: originalPurchaseDate = [RMAppReceipt
formatRFC3339String:RMASN1ReadIA5SString(&p, length)]; break;
case 1708: subscriptionExpirationDate = [RMAppReceipt
formatRFC3339String:RMASN1ReadIA5SString(&p, length)]; break;
case 1711: webOrderLineItemID = RMASN1ReadInteger(&p, length); break;
case 1712: cancellationDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&p,
length)]; break;
}
}];
Demo

github.com/robotmedia/RMStore
About me
Jordi Giménez
• CTO at Mobile Jazz
• Co-organizer of NSBarcelona
• iOS and Android developer
• High-availability, high-scalability
• IT Security
Speech Synthesis with AV Foundation
AV Foundation framework provides essential services for working with time-based audiovisual media.
Play, capture, edit, or encode media.
AV Foundation
Speech synthesis
• AVFoundation allows provides a convenient interface to the speech
synthesizer
AVSpeechSynthesizer *synthesizer = [AVSpeechSynthesizer new];
AVSpeechUtterance *utterance = [AVSpeechUtterance
speechUtteranceWithString:@"Hello world!"];
[synthesizer speakUtterance:utterance];
JavaScriptCore
Evaluate JavaScript in your iOS applications
JavaScriptCore
•
•
•
•

New Objective-C interface
Allows Objective-C Language Binding
Good for JSON parsing/transformation
Platform independent code
JavaScript Execution

// make an execution context
JSContext *context = [[JSContext alloc] initWithVirtualMachine:
[[JSVirtualMachine alloc] init]];
!

// read and write variables
context[@"a"] = @5; // write global variables
JSValue *aValue = context[@"a"]; // read global variables
double a = [aValue toDouble];
JavaScript Execution

// declare a function
[context evaluateScript:@"var square = function(x) {return x*x;}”];
!

// run a function
JSValue *squareFunction = context[@"square"];
JSValue *result = [squareFunction callWithArguments:@[@3]];
JavaScript Execution

// declare a function as an Objective-C block
context[@"square"] = ^(int x) {
return x*x;
};
Networking APIs
New networking APIs
• Multitasking: background execution of network tasks
• AirDrop: data transfer between nearby devices
• Multipeer connectivity: message passing between ad-hoc groups of
people
Multitasking
iOS applications can’t generally run in the background, in order to save
battery and boost performance
• UIBackgroundModes specify when the app should wake up
•

•
•
•
•
•
•
•
•

audio
location
newsstand-content
external-accessory
bluetooth-central
bluetooth-peripherial
fetch
remote-notification
Multitasking
Background fetch: wake up at intervals
// 1. Specify `fetch` in UIBackgroundModes in Info.plist to wake up the application
at intervals.
!

// 2. Give an interval hint:
[[UIApplication sharedApplication]
setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
!

// 3. Handle fetch wakeup
-(void) application:(UIApplication *)application performFetchWithCompletionHandler:
(void(^) (UIBackgroundFetchResult))completionHandler
{
// fetch content from the network
if(newContent) {
completionHandler(UIBackgroundFetchResultNewData);
} else {
completionHandler(UIBackgroundFetchResultNoData);
}
}
Multitasking
Remote notifications: wake up on server demand
// 1. Specify `remote-notification` in UIBackgroundModes in Info.plist to wake up the
application upon reception of push notifications with `content-available=1` attribute.
!

// 2. Handle fetch wakeup
- (void) application:(UIApplication *)application didReceiveRemoteNotification:
(NSDictionary *)userInfo performFetchWithCompletionHandler:(void(^)
(UIBackgroundFetchResult))completionHandler
{
if([[userInfo objectForKey:@"content-available"] intValue] != 1) {
completionHandler(UIBackgroundFetchResultNoData); // no content-available!
return;
}
// fetch content from the network
if(newContent) {
completionHandler(UIBackgroundFetchResultNewData);
} else {
completionHandler(UIBackgroundFetchResultNoData);
}
}
Multitasking
Background Transfer Service

Transferring files can be a problem:
• Intermittent connectivity
• User switching applications
• Network conditioned operations (eg. wifi only)
Multitasking
Background Transfer Service
Uploads/downloads files even if the application is in background
!

1.
2.
3.
4.

Make an NSURLSession with the desired NSURLSessionConfiguration
Provide a session identifier and delegate
Initiate a task
Delegate methods will be called upon progress/completion
Multitasking
Background Transfer Service
The application might be killed while in the background.
!

To deal with background mode, also implement
-application:handleEventsForBackgroundURLSession:completionHandler:

like this:
!

1. Look at the session identifier provided by the system
2. Make an NSURLSession with the desired NSURLSessionConfiguration,
matching the settings for that identifier, with a delegate
3. Delegate methods will be called to notify completion
AirDrop
AirDrop

AirDrop lets users share photos,
documents, URLs (including custom
schemes), and other kinds of data via
Wifi/Bluetooth
!

(See Apple’s AirDropSample)
AirDrop
Sending a file
1. Implement a class with the UIActivityItemSource
protocol

Provides:
• a URL with custom scheme or
• an UTI + NSData.
2. Display a UIActivityViewController to handle
your class instance
!

UIActivityViewController already existed

before to share data between apps, AirDrop was
added
AirDrop
Receiving a file
• Add the document types and URL schemes you want to support (Xcode
Target > Info)
!
!
!
!
!
!

No matter where the file comes from (local or AirDrop) you will
receive it the same way.
AirDrop
Receiving a file
// handle incoming URLs/files
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
if ([url.scheme isEqualToString:@"my-custom-scheme"]) {
// handle custom scheme URL
}
else
{
// read file at URL
}
return YES;
}
Multipeer connectivity
Multipeer connectivity
• Allows to make ad-hoc groups of up to 8 devices in order to share data
(NSData, streams)
• Ideal for games or other kinds of data transfer on the spot
iBeacons
iBeacons
• iBeacons are Bluetooth Low Energy devices emitting an identifier
• CoreLocation integrates natively with iBeacons to provide regions
• Applications can be notified when entering/leaving a region (even in the
background) with very little power consumption
!

• Useful for:
• Locating areas at a retail store
• Augmentation of museum
• Geocaching/scavenger hunt games
• Tourism
iBeacons
Listen for iBeacons
// tell location manager to start monitoring for the beacon region
region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
identifier:@"ibeacon.test"];
!

[locationManager startMonitoringForRegion:region];
[locationManager startRangingBeaconsInRegion:region];
!

// listen for location manager updates
-(void)locationManager:(CLLocationManager*)manager
didRangeBeacons:(NSArray*)beacons
inRegion:(CLBeaconRegion*)region
{
NSLog(@"Beacons found: %@", beacons);
}
iBeacons
Advertising your iDevice
// start the peripheral manager, tells about Bluetooth state
peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil];
!

// listen for bluetooth peripheral updates
-(void)peripheralManagerDidUpdateState:(CBPeripheralManager*)peripheral
{
if (peripheral.state == CBPeripheralManagerStatePoweredOn) {
// makes a region describing this device
CLBeaconRegion *advertisingRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
major:33 minor:44 identifier:@"ibeacon.test"];
// gets this device's data to use as beacon
NSDictionary* beaconData = [advertisingRegion peripheralDataWithMeasuredPower:nil];
// advertises
[self.peripheralManager startAdvertising:beaconData];
}
else if (peripheral.state == CBPeripheralManagerStatePoweredOff)
{
[self.peripheralManager stopAdvertising];
}
}
Wrap up
• Speech synthesis
• JavaScript evaluation
• Networking in the background
• Background fetch
• Remote notification background mode
• Background Transfer Service
• AirDrop & Multi-peer connectivity
• iBeacons
So… What’s new in iOS 7?
OK, you want the full list
• https://developer.apple.com/ios7/
• https://developer.apple.com/library/prerelease/ios/releasenotes/General/
WhatsNewIniOS/Article
Thank you!
!

Check out our sample code at:
github.com/nsbarcelona
Hermes Pique!
@hpique

Jordi Giménez!
jordi@mobilejazz.cat

Weitere ähnliche Inhalte

Was ist angesagt?

Angular 4 with firebase
Angular 4 with firebaseAngular 4 with firebase
Angular 4 with firebaseAnne Bougie
 
FleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in ClojureFleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in ClojureMark McGranaghan
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolboxShem Magnezi
 
FleetDB A Schema-Free Database in Clojure
FleetDB A Schema-Free Database in ClojureFleetDB A Schema-Free Database in Clojure
FleetDB A Schema-Free Database in Clojureelliando dias
 
Leveraging Azure Search in Your Application
Leveraging Azure Search in Your ApplicationLeveraging Azure Search in Your Application
Leveraging Azure Search in Your ApplicationJeremy Hutchinson
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataEvan Rodd
 
Back to basics Italian webinar 2 Mia prima applicazione MongoDB
Back to basics Italian webinar 2  Mia prima applicazione MongoDBBack to basics Italian webinar 2  Mia prima applicazione MongoDB
Back to basics Italian webinar 2 Mia prima applicazione MongoDBMongoDB
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!Sébastien Levert
 
Dropwizard with MongoDB and Google Cloud
Dropwizard with MongoDB and Google CloudDropwizard with MongoDB and Google Cloud
Dropwizard with MongoDB and Google CloudYun Zhi Lin
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...Sencha
 
APIs, APIs Everywhere!
APIs, APIs Everywhere!APIs, APIs Everywhere!
APIs, APIs Everywhere!BIWUG
 
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)Sirar Salih
 
Desenvolvimento web com Ruby on Rails (extras)
Desenvolvimento web com Ruby on Rails (extras)Desenvolvimento web com Ruby on Rails (extras)
Desenvolvimento web com Ruby on Rails (extras)Joao Lucas Santana
 
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB
 

Was ist angesagt? (20)

Angular 4 with firebase
Angular 4 with firebaseAngular 4 with firebase
Angular 4 with firebase
 
What's Parse
What's ParseWhat's Parse
What's Parse
 
Parse Advanced
Parse AdvancedParse Advanced
Parse Advanced
 
FleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in ClojureFleetDB: A Schema-Free Database in Clojure
FleetDB: A Schema-Free Database in Clojure
 
Html indexed db
Html indexed dbHtml indexed db
Html indexed db
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
FleetDB A Schema-Free Database in Clojure
FleetDB A Schema-Free Database in ClojureFleetDB A Schema-Free Database in Clojure
FleetDB A Schema-Free Database in Clojure
 
Leveraging Azure Search in Your Application
Leveraging Azure Search in Your ApplicationLeveraging Azure Search in Your Application
Leveraging Azure Search in Your Application
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your Data
 
Mongo db for C# Developers
Mongo db for C# DevelopersMongo db for C# Developers
Mongo db for C# Developers
 
Mongo db for c# developers
Mongo db for c# developersMongo db for c# developers
Mongo db for c# developers
 
Back to basics Italian webinar 2 Mia prima applicazione MongoDB
Back to basics Italian webinar 2  Mia prima applicazione MongoDBBack to basics Italian webinar 2  Mia prima applicazione MongoDB
Back to basics Italian webinar 2 Mia prima applicazione MongoDB
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
 
Dropwizard with MongoDB and Google Cloud
Dropwizard with MongoDB and Google CloudDropwizard with MongoDB and Google Cloud
Dropwizard with MongoDB and Google Cloud
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
 
APIs, APIs Everywhere!
APIs, APIs Everywhere!APIs, APIs Everywhere!
APIs, APIs Everywhere!
 
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)Azure Table Storage: The Good, the Bad, the Ugly (full talk)
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
 
Desenvolvimento web com Ruby on Rails (extras)
Desenvolvimento web com Ruby on Rails (extras)Desenvolvimento web com Ruby on Rails (extras)
Desenvolvimento web com Ruby on Rails (extras)
 
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
 

Andere mochten auch

Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)
Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)
Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)barcelonaio
 
Medical Mobile Apps by Joachim Neumann (NSBarcelona)
Medical Mobile Apps by Joachim Neumann (NSBarcelona)Medical Mobile Apps by Joachim Neumann (NSBarcelona)
Medical Mobile Apps by Joachim Neumann (NSBarcelona)barcelonaio
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

Andere mochten auch (7)

FoodLinker
FoodLinkerFoodLinker
FoodLinker
 
Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)
Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)
Bluetooth LE & iBeacons by Javier Chávarri (NSBarcelona)
 
Wake Up
Wake UpWake Up
Wake Up
 
Capitulo I ezzio
Capitulo I ezzioCapitulo I ezzio
Capitulo I ezzio
 
Medical Mobile Apps by Joachim Neumann (NSBarcelona)
Medical Mobile Apps by Joachim Neumann (NSBarcelona)Medical Mobile Apps by Joachim Neumann (NSBarcelona)
Medical Mobile Apps by Joachim Neumann (NSBarcelona)
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Ähnlich wie What's new in iOS 7

Converting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudConverting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudRoger Brinkley
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps OfflinePedro Morais
 
Interconnect Mobile Application Development on Bluemix!!
Interconnect Mobile Application Development on Bluemix!!Interconnect Mobile Application Development on Bluemix!!
Interconnect Mobile Application Development on Bluemix!!Todd Kaplinger
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
End to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaEnd to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaBabacar NIANG
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureiMasters
 
Saving Time And Effort With QuickBase Api - Sergio Haro
Saving Time And Effort With QuickBase Api - Sergio HaroSaving Time And Effort With QuickBase Api - Sergio Haro
Saving Time And Effort With QuickBase Api - Sergio HaroQuickBase, Inc.
 
Parse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & TricksParse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & TricksHector Ramos
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Dan Wahlin
 
Core Data with multiple managed object contexts
Core Data with multiple managed object contextsCore Data with multiple managed object contexts
Core Data with multiple managed object contextsMatthew Morey
 
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013Amazon Web Services
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsVu Tran Lam
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson PortfolioKbengt521
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaDroidConTLV
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRJavier Abadía
 

Ähnlich wie What's new in iOS 7 (20)

Converting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudConverting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile Cloud
 
Html5 Overview
Html5 OverviewHtml5 Overview
Html5 Overview
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
 
Interconnect Mobile Application Development on Bluemix!!
Interconnect Mobile Application Development on Bluemix!!Interconnect Mobile Application Development on Bluemix!!
Interconnect Mobile Application Development on Bluemix!!
 
iOS 7 SDK特訓班
iOS 7 SDK特訓班iOS 7 SDK特訓班
iOS 7 SDK特訓班
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
End to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaEnd to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux Saga
 
Android development
Android developmentAndroid development
Android development
 
UIWebView Tips
UIWebView TipsUIWebView Tips
UIWebView Tips
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean Architecture
 
Saving Time And Effort With QuickBase Api - Sergio Haro
Saving Time And Effort With QuickBase Api - Sergio HaroSaving Time And Effort With QuickBase Api - Sergio Haro
Saving Time And Effort With QuickBase Api - Sergio Haro
 
Parse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & TricksParse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & Tricks
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
 
Core Data with multiple managed object contexts
Core Data with multiple managed object contextsCore Data with multiple managed object contexts
Core Data with multiple managed object contexts
 
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code Listings
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson Portfolio
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice Ninja
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMR
 

Kürzlich hochgeladen

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Kürzlich hochgeladen (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

What's new in iOS 7

  • 1. What’s new in iOS 7? Highlights of 1500 new APIs Jordi Gimenez (@gimix3) & Hermes Pique (@hpique) NSBarcelona
  • 2. 82% of devices are using iOS 7. As measured by the App Store during a 7-day period ending February 23, 2014.
  • 3. Agenda What we will cover • • • • • • • NSTextStorage UIViewController transitions iCloud & Core Data App Store Receipt Speech Synthesis JavaScript Evaluation New Networking Possibilities
  • 5. Text Kit UILabel UITextView Text Kit Core Text Core Graphics UITextField
  • 7. Text Kit Use defaults or provide your own classes textStorage = [NSTextStorage new]; layoutManager = [NSLayoutManager new]; textContainer = [[NSTextContainer alloc] initWithSize:size]; [layoutManager addTextContainer:textContainer]; [textStorage addLayoutManager:layoutManager]; ! textView = [[UITextView alloc] initWithFrame:frame textContainer:textContainer];
  • 8. Text Kit NSTextStorage • NSMutableAttributedString subclass • Subclass to provide custom editing - (void)processEditing { [_backingStore beginEditing]; // Custom editing [_backingStore endEditing]; [super processEditing]; }
  • 9. Text Kit Using images in NSTextStorage (void)replaceLettersInRange:(NSRange)range { [backingStore.string enumerateSubstringsInRange:range options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { ! NSTextAttachment *textAttachment = [NSTextAttachment new]; textAttachment.image = [self imageForString:substring]; NSAttributedString *attributed = [NSAttributedString attributedStringWithAttachment:textAttachment]; [backingStore replaceCharactersInRange:substringRange withAttributedString:attributed]; ! }]; }
  • 12. UIViewController Transitions Customizable transitions • • • • Presentations and dismissals UINavigationController UITabBarController UICollectionViewController layout-to-layout
  • 13. UIViewController Transitions The container view Container view UIViewController A UIViewController B View A View B
  • 14. UIViewController Transitions Returning the transition animation - (id <UIViewControllerAnimatedTransitioning>)navigationController: (UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { id<UIViewControllerAnimatedTransitioning> animator = [MyAnimationController new]; return animator; }
  • 15. UIViewController Transitions Animating the transition - (void)animateTransition:(id <UIViewControllerContextTransitioning>)context { ! UIViewController *fromVC = [context viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toVC = [context viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = context.containerView; [container insertSubview:toViewController.view aboveSubview:fromViewController.view]; ! // Prepare for animation ! NSTimeInterval duration = [self transitionDuration:context]; [UIView animateWithDuration:duration animations:^{ // Animations } completion:^(BOOL finished) { // Cleanup and restore state [context completeTransition:YES]; }]; }
  • 17. Adding iCloud to Core Data
  • 18. “…the average [US] household has 1.6 Apple devices.” –CNBC in 2012
  • 19. iCloud • Using iCloud in iOS 5-6 is a bug • Sync network setup (!) • Limited APIs • Poor support for account changes • Unreliability • In iOS 7 it’s actually usable
  • 20. iCloud Core Data with iCloud in 3 steps 1. Add iCloud to Core Data 2. Respond to changes 3. Respond to account changes
  • 21. iCloud Adding iCloud to Core Data NSDictionary *options = @{ NSPersistentStoreUbiquitousContentNameKey : @"name" } ! [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:options error:&error];
  • 22. iCloud Responding to changes NSPersistentStoreDidImportUbiquitousContentChangesNotification ! ! [moc performBlockAndWait:^{ [moc mergeChangesFromContextDidSaveNotification:notification]; }];
  • 23. iCloud Responding to account changes NSPersistentStoreCoordinatorStoresWillChangeNotification ! ! dispatch_sync(dispatch_get_main_queue(), ^{ // Prepare UI }); [moc performBlockAndWait:^{ NSError *error = nil; if ([moc hasChanges]) { [moc save:&error]; } [moc reset]; }];
  • 24. iCloud Responding to account changes NSPersistentStoreCoordinatorStoresDidChangeNotification ! ! dispatch_sync(dispatch_get_main_queue(), ^{ // Update UI });
  • 26. The App Store Receipt
  • 27. “This is doable.” –James Wilson (Engineering Manager for the App Store in OS X) at WWDC 2013, about verifying the App Store receipt
  • 28. App Store Receipt Verification in 5 steps 1. 2. 3. 4. 5. Get the receipt data Verify the receipt signature Get the receipt fields Verify the receipt hash Get in-app purchases (optional)
  • 29. App Store Receipt Getting the receipt data const char *cpath = [[path stringByStandardizingPath] fileSystemRepresentation]; FILE *fp = fopen(cpath, "rb"); if (!fp) return nil; ! PKCS7 *p7 = d2i_PKCS7_fp(fp, NULL); fclose(fp); if (!p7) return nil; ! NSURL *certificateURL = [[NSBundle mainBundle] URLForResource:@"AppleIncRootCertificate" withExtension:@"cer"]; NSData *certificateData = [NSData dataWithContentsOfURL:certificateURL]; if ([self verifyPCKS7:p7 withCertificateData:certificateData]) { struct pkcs7_st *contents = p7->d.sign->contents; if (PKCS7_type_is_data(contents)) { ASN1_OCTET_STRING *octets = contents->d.data; data = [NSData dataWithBytes:octets->data length:octets->length]; } } PKCS7_free(p7);
  • 30. App Store Receipt Verifying the receipt signature int result = 0; OpenSSL_add_all_digests(); // Required for PKCS7_verify to work X509_STORE *store = X509_STORE_new(); if (store) { const uint8_t *certificateBytes = (uint8_t *)(certificateData.bytes); X509 *certificate = d2i_X509(NULL, &certificateBytes (long)certificateData.length); if (certificate){ X509_STORE_add_cert(store, certificate); BIO *payload = BIO_new(BIO_s_mem()); result = PKCS7_verify(container, NULL, store, NULL, payload, 0); BIO_free(payload); X509_free(certificate); } } X509_STORE_free(store); EVP_cleanup();
  • 31. App Store Receipt Getting the receipt fields [RMAppReceipt enumerateASN1Attributes:asn1Data.bytes length:asn1Data.length usingBlock:^(NSData *data, int type) { const uint8_t *s = data.bytes; const NSUInteger length = data.length; switch (type) { case 2: bundleIdData = data; _bundleId = RMASN1ReadUTF8String(&s, length); break; case 3: appVersion = RMASN1ReadUTF8String(&s, length); break; case 4: opaqueValue = data; break; case 5: hash = data; break; case 17: { RMAppReceiptIAP *purchase = [[RMAppReceiptIAP alloc] initWithASN1Data:data]; [purchases addObject:purchase]; break; } case 19: originalAppVersion = RMASN1ReadUTF8String(&s, length); break; case 21: expirationDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&s, length)]; break; } }];
  • 32. App Store Receipt Verifying the receipt hash NSUUID *uuid = [[UIDevice currentDevice] identifierForVendor]; unsigned char uuidBytes[16]; [uuid getUUIDBytes:uuidBytes]; ! NSMutableData *data = [NSMutableData data]; [data appendBytes:uuidBytes length:sizeof(uuidBytes)]; [data appendData:opaqueValue]; [data appendData:bundleIdData]; ! NSMutableData *expectedHash = [NSMutableData dataWithLength:SHA_DIGEST_LENGTH]; SHA1(data.bytes, data.length, expectedHash.mutableBytes); ! BOOL verified = [expectedHash isEqualToData:hash];
  • 33. App Store Receipt Getting the in-app purchases [RMAppReceipt enumerateASN1Attributes:asn1Data.bytes length:asn1Data.length usingBlock:^(NSData *data, int type) { const uint8_t *p = data.bytes; const NSUInteger length = data.length; switch (type) { case 1701: quantity = RMASN1ReadInteger(&p, length); break; case 1702: productId = RMASN1ReadUTF8String(&p, length); break; case 1703: transactionIdentifier = RMASN1ReadUTF8String(&p, length); break; case 1704: purchaseDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&p, length)]; case 1705: originalTransactionId = RMASN1ReadUTF8String(&p, length); break; case 1706: originalPurchaseDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&p, length)]; break; case 1708: subscriptionExpirationDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&p, length)]; break; case 1711: webOrderLineItemID = RMASN1ReadInteger(&p, length); break; case 1712: cancellationDate = [RMAppReceipt formatRFC3339String:RMASN1ReadIA5SString(&p, length)]; break; } }];
  • 35. About me Jordi Giménez • CTO at Mobile Jazz • Co-organizer of NSBarcelona • iOS and Android developer • High-availability, high-scalability • IT Security
  • 36. Speech Synthesis with AV Foundation AV Foundation framework provides essential services for working with time-based audiovisual media. Play, capture, edit, or encode media.
  • 37. AV Foundation Speech synthesis • AVFoundation allows provides a convenient interface to the speech synthesizer AVSpeechSynthesizer *synthesizer = [AVSpeechSynthesizer new]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Hello world!"]; [synthesizer speakUtterance:utterance];
  • 38. JavaScriptCore Evaluate JavaScript in your iOS applications
  • 39. JavaScriptCore • • • • New Objective-C interface Allows Objective-C Language Binding Good for JSON parsing/transformation Platform independent code
  • 40. JavaScript Execution // make an execution context JSContext *context = [[JSContext alloc] initWithVirtualMachine: [[JSVirtualMachine alloc] init]]; ! // read and write variables context[@"a"] = @5; // write global variables JSValue *aValue = context[@"a"]; // read global variables double a = [aValue toDouble];
  • 41. JavaScript Execution // declare a function [context evaluateScript:@"var square = function(x) {return x*x;}”]; ! // run a function JSValue *squareFunction = context[@"square"]; JSValue *result = [squareFunction callWithArguments:@[@3]];
  • 42. JavaScript Execution // declare a function as an Objective-C block context[@"square"] = ^(int x) { return x*x; };
  • 44. New networking APIs • Multitasking: background execution of network tasks • AirDrop: data transfer between nearby devices • Multipeer connectivity: message passing between ad-hoc groups of people
  • 45. Multitasking iOS applications can’t generally run in the background, in order to save battery and boost performance • UIBackgroundModes specify when the app should wake up • • • • • • • • • audio location newsstand-content external-accessory bluetooth-central bluetooth-peripherial fetch remote-notification
  • 46. Multitasking Background fetch: wake up at intervals // 1. Specify `fetch` in UIBackgroundModes in Info.plist to wake up the application at intervals. ! // 2. Give an interval hint: [[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; ! // 3. Handle fetch wakeup -(void) application:(UIApplication *)application performFetchWithCompletionHandler: (void(^) (UIBackgroundFetchResult))completionHandler { // fetch content from the network if(newContent) { completionHandler(UIBackgroundFetchResultNewData); } else { completionHandler(UIBackgroundFetchResultNoData); } }
  • 47. Multitasking Remote notifications: wake up on server demand // 1. Specify `remote-notification` in UIBackgroundModes in Info.plist to wake up the application upon reception of push notifications with `content-available=1` attribute. ! // 2. Handle fetch wakeup - (void) application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo performFetchWithCompletionHandler:(void(^) (UIBackgroundFetchResult))completionHandler { if([[userInfo objectForKey:@"content-available"] intValue] != 1) { completionHandler(UIBackgroundFetchResultNoData); // no content-available! return; } // fetch content from the network if(newContent) { completionHandler(UIBackgroundFetchResultNewData); } else { completionHandler(UIBackgroundFetchResultNoData); } }
  • 48. Multitasking Background Transfer Service Transferring files can be a problem: • Intermittent connectivity • User switching applications • Network conditioned operations (eg. wifi only)
  • 49. Multitasking Background Transfer Service Uploads/downloads files even if the application is in background ! 1. 2. 3. 4. Make an NSURLSession with the desired NSURLSessionConfiguration Provide a session identifier and delegate Initiate a task Delegate methods will be called upon progress/completion
  • 50. Multitasking Background Transfer Service The application might be killed while in the background. ! To deal with background mode, also implement -application:handleEventsForBackgroundURLSession:completionHandler: like this: ! 1. Look at the session identifier provided by the system 2. Make an NSURLSession with the desired NSURLSessionConfiguration, matching the settings for that identifier, with a delegate 3. Delegate methods will be called to notify completion
  • 52. AirDrop AirDrop lets users share photos, documents, URLs (including custom schemes), and other kinds of data via Wifi/Bluetooth ! (See Apple’s AirDropSample)
  • 53. AirDrop Sending a file 1. Implement a class with the UIActivityItemSource protocol
 Provides: • a URL with custom scheme or • an UTI + NSData. 2. Display a UIActivityViewController to handle your class instance ! UIActivityViewController already existed before to share data between apps, AirDrop was added
  • 54. AirDrop Receiving a file • Add the document types and URL schemes you want to support (Xcode Target > Info) ! ! ! ! ! ! No matter where the file comes from (local or AirDrop) you will receive it the same way.
  • 55. AirDrop Receiving a file // handle incoming URLs/files - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { if ([url.scheme isEqualToString:@"my-custom-scheme"]) { // handle custom scheme URL } else { // read file at URL } return YES; }
  • 57. Multipeer connectivity • Allows to make ad-hoc groups of up to 8 devices in order to share data (NSData, streams) • Ideal for games or other kinds of data transfer on the spot
  • 59. iBeacons • iBeacons are Bluetooth Low Energy devices emitting an identifier • CoreLocation integrates natively with iBeacons to provide regions • Applications can be notified when entering/leaving a region (even in the background) with very little power consumption ! • Useful for: • Locating areas at a retail store • Augmentation of museum • Geocaching/scavenger hunt games • Tourism
  • 60. iBeacons Listen for iBeacons // tell location manager to start monitoring for the beacon region region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"ibeacon.test"]; ! [locationManager startMonitoringForRegion:region]; [locationManager startRangingBeaconsInRegion:region]; ! // listen for location manager updates -(void)locationManager:(CLLocationManager*)manager didRangeBeacons:(NSArray*)beacons inRegion:(CLBeaconRegion*)region { NSLog(@"Beacons found: %@", beacons); }
  • 61. iBeacons Advertising your iDevice // start the peripheral manager, tells about Bluetooth state peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil]; ! // listen for bluetooth peripheral updates -(void)peripheralManagerDidUpdateState:(CBPeripheralManager*)peripheral { if (peripheral.state == CBPeripheralManagerStatePoweredOn) { // makes a region describing this device CLBeaconRegion *advertisingRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:33 minor:44 identifier:@"ibeacon.test"]; // gets this device's data to use as beacon NSDictionary* beaconData = [advertisingRegion peripheralDataWithMeasuredPower:nil]; // advertises [self.peripheralManager startAdvertising:beaconData]; } else if (peripheral.state == CBPeripheralManagerStatePoweredOff) { [self.peripheralManager stopAdvertising]; } }
  • 62. Wrap up • Speech synthesis • JavaScript evaluation • Networking in the background • Background fetch • Remote notification background mode • Background Transfer Service • AirDrop & Multi-peer connectivity • iBeacons
  • 63. So… What’s new in iOS 7? OK, you want the full list • https://developer.apple.com/ios7/ • https://developer.apple.com/library/prerelease/ios/releasenotes/General/ WhatsNewIniOS/Article
  • 64. Thank you! ! Check out our sample code at: github.com/nsbarcelona Hermes Pique! @hpique Jordi Giménez! jordi@mobilejazz.cat