IOS 10/swift 3.0/xcode 8 Summary

Source: Internet
Author: User

1,IOS10 New Privacy settings

IOS10 added a new permission control scope if you try to access these privacy data, you get the following error:

> This app have crashed because it attempted to access privacy-sensitive> data without a usage description.  The app ' s info.plist must contain> an nscamerausagedescription key with a string value explaining to the> user how T He app uses this data

Because it attempts to access sensitive data when there is no info.plist in the application
Set privacy key to the new privacy setting as follows:


Privacy Setting2, Os_activity_mode

Update Xcode 8 If the console appears enable_level:0, persist_level:0, default_ttl:0, info_ttl:0, debug_ttl:0, Generate_symptoms:0enable_ Oversize: The following methods can be set:

Edit scheme-> Run, Arguments, add os_activity_mode = Disable inside environment variables
3,IOS10 Layoutifneed

IOS10 calling Layoutifneed on a control will only evaluate the constraint separately, and the control it constrains will not take effect, and the previous effect needs to be called on the parent control layoutifneed

4, NSDate

SWIFT3.0 will convert OC nsdate to data type, and some operations nsdate third-party libraries will flash back

5, Notification

SWIFT3.0 a notification constant of a string type is defined as a struct

static Let Mygreatnotification = Notification.name ("mygreatnotification")//Use site (no change) Notificationcenter.default (). Post (name:MyController.MyGreatNotification, object:self) '
6, Zip2sequence ( ::) be removed

The Swift3.0zip2sequence (_:_:) method is replaced with a zip (_:_:)

7, range<>.reversed is removed

After the Swift3.0range<>.reversed method is removed, it is replaced with <collection>[<range>].indices.reversed ().

var array = ["A", "B", "C", "D"]for I in array.indices.reversed () {    print ("\ (i)")} Output: 3 2 1 0
8, range added to four types
Rangecountablerangeclosedrangecountableclosedrange

Different expressions generate a different range

var countablerange = 0..<20 ' Countablerange (0..<20) ' var countableclosedrange = 0...20 ' Countableclosedrange ( 0...20) '
9, Swift3.0 Collection New Index (_:) Series method

Index successor (), predecessor (), Advancedby (_:), Advancedby (_:limit:), or Distanceto (_:) methods are removed, and these operations are moved to collection

Myindex.successor ()  =  Mycollection.index (after:myindex) myindex.predecessor ()  =  Mycollection.index (Before:myindex) myindex.advance (by: ...) = Mycollection.index (Myindex, Offsetby: ...)
IOS10 Uistatusbar Expired

If you need to operate Uistatusbar, the IOS10 needs to be changed to

-(Uistatusbarstyle) Preferredstatusbarstyle {    return uistatusbarstyledefault;}
One, iOS10 uicollectionview performance optimization

The biggest change in iOS10 Uicollectionview is the addition of pre-fetching (preload),
If you look at Uicollectionview's latest API you can see that the following properties have been added:

@property (nonatomic, weak, nullable) id<uicollectionviewdatasourceprefetching> Prefetchdatasource @property ( Nonatomic, getter=isprefetchingenabled) BOOL

The iOS10 pre-fetching is turned on by default, and if for some reason you do not want to turn on pre-fetching, you can disable it by setting the following:

Collectionview.isprefetchingenabled = False

The uicollectionviewdatasourceprefetching protocol is defined as follows:

@protocol uicollectionviewdatasourceprefetching <NSObject> @required//Indexpaths is ordered ascending by Geometric distance from the collection view-(void) CollectionView: (Uicollectionview *) CollectionView Prefetchitemsatindexpaths: (Nsarray<nsindexpath *> *) indexpaths Ns_available_ios (10_0); @optional//IndexPaths That previously were considered as candidates for pre-fetching, but were not actually used; May is a subset of the previous call to-collectionview:prefetchitemsatindexpaths:-(void) CollectionView: ( Uicollectionview *) CollectionView cancelprefetchingforitemsatindexpaths: (Nsarray<nsindexpath *> *) indexPaths  Ns_available_ios (10_0); @end
iOS10 UITableView Performance Optimization

As with Uicollectionview UITableView also adds pre-fetching technology, UITableView adds the following properties:

@property (nonatomic, weak) id<uitableviewdatasourceprefetching> Prefetchdatasource Ns_available_ios (10_0);

Strangely, UITableView did not find the definition of the isprefetchingenabled attribute.

13,ios10 Uiscrollview New Refreshcontrol Properties

Uiscrollview added the Refreshcontrol property

@property (Nonatomic, Strong, nullable) Uirefreshcontrol *refreshcontrol Ns_available_ios (10_0) __tvos_prohibited;

This means that both Uicollectionview and UITableView support the Refresh function.

We can also use Uirefreshcontrol out of Uitableviewcontroller.

Swif3.0 New scope access level Fileprivate

There are currently the following access levels:

    • Open (public)
    • Internal (internal)
    • Out-of-file private (Fileprivate)
    • Proprietary (private)
15,swift3.0 allow keywords as parameter labels

Swift3.0 start we will be able to use the inout var let keyword as the parameter label

Swift 3 calling with argument label:    calculaterevenue (for Sales:numberofcopies, in                     . dollars)    //Swift 3 de Claring with argument label:    calculaterevenue (for Sales:int, in                     currency:currency)    func touchesmatching ( Phase:nstouchphase, in View:nsview?) Set<nstouch>

If you insist on using the inout var let keyword you can use the ' Wrap parameter label

Func addparameter (name:string, ' inout ': Bool)

IOS 10/swift 3.0/xcode 8 Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.