Top Banner
THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE USE OF ANIMATIONS AND IMAGES OF QUESTIONABLE TASTE THOSE OF A SENSITIVE NATURE SHOULD LEAVE NOW Tuesday, 29 October 13
51

THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Jun 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

THE FOLLOWING PRESENTATION MAY CONTAIN

EXCESSIVE USE OF ANIMATIONSAND

IMAGES OF QUESTIONABLE TASTETHOSE OF A SENSITIVE NATURE SHOULD LEAVE NOW

Tuesday, 29 October 13

Page 2: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7

Tuesday, 29 October 13

Page 3: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7

TextKit

UIKit Dynamics

Multitasking

NSURLSession

NSProgress

SpriteKit

Game Controllers

AirDrop

Inter-App Audio

Multipeer Connectivity

JavaScript Core

Media Accessibility

Safari Services

OpenGL ES 3.0

Message Attachments

NSURLComponentsiBeacons

Modules

Tuesday, 29 October 13

Page 4: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7…

Tuesday, 29 October 13

Page 5: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7for Hipsters

Tuesday, 29 October 13

Page 6: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7for Hipsters

Tuesday, 29 October 13

Page 7: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Until…

Tuesday, 29 October 13

Page 8: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

NSi OS 7With the NDA finally lifted, we can finally talk about all of the amazing new APIs in iOS 7. And thereare a lot of them. "1500 new APIs", by Apple's count during the WWDC Keynote. (Granted, a goodportion of that could just be all of the changes from id to instancetype, but that's a hugenumber, regardless).

We'll be going over many of the new features iOS 7 in depth over the coming weeks, but with all ofthe excitement around this major release, this week's issue will hit on some of the gems hiding inplain sight: NSData Base64 encoding, NSURLComponents, NSProgress, NSProcessInfoactivities, CIDetectorSmile, CIDetectorEyeBlink, SSReadingList,AVCaptureMetaDataOutput, AVSpeechSynthesizer, and MKDistanceFormatter.

NSData (NSDataBase64Encoding)

Written by Mattt Thompson on Sep 23rd, 2013

Tuesday, 29 October 13

Page 9: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7for Hipsters

Tuesday, 29 October 13

Page 10: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

What’s New in iOS 7 for the Hipster’s Hipster

Tuesday, 29 October 13

Page 11: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

But first

Tuesday, 29 October 13

Page 12: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

But first

A dirty secret

Tuesday, 29 October 13

Page 13: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

But first

A dirty secret

I’m a Mac developer

Tuesday, 29 October 13

Page 14: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

GCD

FoundationImageIO

CoreFoundation

CoreGraphics

Tuesday, 29 October 13

Page 15: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

Tuesday, 29 October 13

Page 16: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

• Introduced in OS X 10.7 / iOS 5

Tuesday, 29 October 13

Page 17: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

• Introduced in OS X 10.7 / iOS 5

• C-level immutable container for raw data, similar to NSData

Tuesday, 29 October 13

Page 18: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

NSData

NSData

Tuesday, 29 October 13

Page 19: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

NSData

NSDataNSMutableData

Tuesday, 29 October 13

Page 20: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

NSData

NSData

[ appendData:

[ appendData:

]

]NSMutableData

Tuesday, 29 October 13

Page 21: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

NSData

NSData

[ appendData:

[ appendData:

]

]bytesNSMutableDataNSMutableData

Tuesday, 29 October 13

Page 22: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

NSData

NSData

[ appendData:

[ appendData:

]

]bytesbytesNSMutableDataNSMutableDataNSMutableData

Tuesday, 29 October 13

Page 23: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

• Bytes are copied, potentially wastefully

Concatenating Data

NSData

NSData

[ appendData:

[ appendData:

]

]bytesbytesNSMutableDataNSMutableDataNSMutableData

Tuesday, 29 October 13

Page 24: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

dispatch_data_t

dispatch_data_t

Tuesday, 29 October 13

Page 25: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Concatenating Data

dispatch_data_t

dispatch_data_tdispatch_data_create_concat( )

Tuesday, 29 October 13

Page 26: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data_t

Concatenating Data

dispatch_data_tdispatch_data_t

dispatch_data_create_concat( )

Tuesday, 29 October 13

Page 27: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data_t

Concatenating Data

dispatch_data_tdispatch_data_t

dispatch_data_create_concat( )

• References, rather than copies the raw bytes

Tuesday, 29 October 13

Page 28: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

“Alright, neat, but how does it affect me?”

Tuesday, 29 October 13

Page 29: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

Tuesday, 29 October 13

Page 30: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

• Toll-free bridged with NSData

• dispatch_data_t can be freely cast to NSData *

• But not vice versa

Tuesday, 29 October 13

Page 31: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

• Toll-free bridged with NSData

• dispatch_data_t can be freely cast to NSData *

• But not vice versa

• NSData instances may now contain non-contiguous bytes

Tuesday, 29 October 13

Page 32: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

• Toll-free bridged with NSData

• dispatch_data_t can be freely cast to NSData *

• But not vice versa

• NSData instances may now contain non-contiguous bytes

• -[NSData bytes] might have to make a copy of the bytes for you

Tuesday, 29 October 13

Page 33: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

dispatch_data

• Toll-free bridged with NSData

• dispatch_data_t can be freely cast to NSData *

• But not vice versa

• NSData instances may now contain non-contiguous bytes

• -[NSData bytes] might have to make a copy of the bytes for you

• Switch from -bytes to -enumerateByteRangesUsingBlock:

Tuesday, 29 October 13

Page 34: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Memory Management

• When using ARC, still have to drop down to manual reference counting for CoreFoundation objects sometimes:

• CFRetain()

• CFRelease()

Tuesday, 29 October 13

Page 35: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Memory Management

• When using ARC, still have to drop down to manual reference counting for CoreFoundation objects sometimes:

• CFRetain()

• CFRelease()

• CFAutorelease()

Tuesday, 29 October 13

Page 36: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

CFStream scheduling

• So far have been scheduled on run loops

• Convenient on the main thread

• More of a hassle on other threads; likely have to run the run loop yourself

Tuesday, 29 October 13

Page 37: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

CFStream scheduling

• So far have been scheduled on run loops

• Convenient on the main thread

• More of a hassle on other threads; likely have to run the run loop yourself

• CFReadStreamSetDispatchQueue() and CFWriteStreamSetDispatchQueue()

Tuesday, 29 October 13

Page 38: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

CFStream scheduling

• So far have been scheduled on run loops

• Convenient on the main thread

• More of a hassle on other threads; likely have to run the run loop yourself

• CFReadStreamSetDispatchQueue() and CFWriteStreamSetDispatchQueue()

• Should work for NSInputStream And NSOutputStream too thanks to toll-free bridging

Tuesday, 29 October 13

Page 39: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Base64

Tuesday, 29 October 13

Page 40: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Base64

• New methods on NSData for Base64 encoding and decoding

Tuesday, 29 October 13

Page 41: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Base64

• New methods on NSData for Base64 encoding and decoding

• But you knew that already, right?

Tuesday, 29 October 13

Page 42: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Base64

• New methods on NSData for Base64 encoding and decoding

• But you knew that already, right?

• Rudimentary support is available back to OS X 10.6 / iOS 4

- (id)initWithBase64Encoding:(NSString *)base64String;

- (NSString *)base64Encoding;

Tuesday, 29 October 13

Page 43: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Sorting and Filtering NSOrderedArray

-sortedArrayUsingDescriptors:

-sortUsingDescriptors:

-filteredOrderedSetUsingPredicate:

-filterUsingPredicate:

• Been there as long as NSOrderedSet itself, but only just exposed

Tuesday, 29 October 13

Page 44: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

NSSecureCoding

• Extension to NSCoding

• Introduced in OS X 10.8 / iOS 6

• Protects against corrupt or maliciously crafted archives

-decodeObjectOfClass:forKey:

-decodeObjectOfClasses:forKey:

• Only protects against class changes

Tuesday, 29 October 13

Page 45: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

NSSecureCoding

• Deeper checking through -allowEvaluation on classes:

• NSSortDescriptor

• NSPredicate

• NSExpression

• Check the key paths etc. of an object to check they’re suitable for your app, then call -allowEvaluation

Tuesday, 29 October 13

Page 46: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

NSSecureCoding — General Advice

1.Adopt instead of raw NSCoding

2.Tell decoder to use it:

‑[NSKeyedUnarchiver setRequiresSecureCoding:YES]

Doesn’t have to be done at the same time as 1.

Tuesday, 29 October 13

Page 47: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

CGPathCreateWithRoundedRect()

• How did it take this long?!

Tuesday, 29 October 13

Page 48: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

CGImageSource workflow

• On worker thread:

• Create CGImageSource

• Retrieve CGImage

• Draw into a small bitmap context to force decompression

• On main thread

• Draw into desired context

Tuesday, 29 October 13

Page 49: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

kCGImageSourceShouldCacheImmediately

• Pass as a flag when retrieving a CGImage

• Should force decompression without all that tedious mucking about in hyperspace bitmap contexts

• Test and Measure; don’t use blindly!

Tuesday, 29 October 13

Page 50: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Bonus Hipster Quiz Question

What is the only public class in the Cocoa frameworks that has no methods of its own?

Tuesday, 29 October 13

Page 51: THE FOLLOWING PRESENTATION MAY CONTAIN EXCESSIVE …mikeabdullah.net/whats-new-in-ios-7/whats-new-in-ios-7-for.pdf · • -[NSData bytes] might have to make a copy of the bytes for

Bonus Hipster Quiz Question

“you wouldn’t have heard of it…”

What is the only public class in the Cocoa frameworks that has no methods of its own?

Tuesday, 29 October 13