iOS 10 / Swift 3.0 / XCode 8 总结
1,iOS10 新增的privacy settings
iOS10添加了新的权限控制范围 如果你尝试访问这些隐私数据时得到如下错误:
> This app has 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 the app uses this data
因为它企图访问敏感数据时没有在应用程序的Info.plist
设置privacy key 新增的privacy setting如下:
2, OS_ACTIVITY_MODE
更新Xcode 8 如果控制台出现enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0enable_oversize: 可通过如下方法设置:
Edit Scheme-> Run -> Arguments,
在Environment Variables里边添加
OS_ACTIVITY_MODE = Disable
3,iOS10 layoutIfNeed
iOS10 在一个控件上调用layoutIfNeed是只会单独计算约束,它所约束的控件不会生效,想要达到之前的效果需要在父级控件上调用layoutIfNeed
4, NSDate
Swift3.0会将oc的NSDate转为Data类型,有些操作NSDate的第三方库会闪退
5, Notification
Swift3.0字符串类型的通知常量被定义为struct
static let MyGreatNotification = Notification.Name("MyGreatNotification")
// Use site (no change)
NotificationCenter.default().post(name: MyController.MyGreatNotification, object: self)'
6, Zip2Sequence(::) 被移除
在Swift3.0Zip2Sequence(_:_:)方法被替换为zip(_:_:)
7, Range<>.reversed 被移除
在Swift3.0Range<>.reversed方法被移除,被替换为<Collection>[<Range>].indices.reversed().
var array = ["A","B","C","D"]
for i in array.indices.reversed() {
print("\(i)")
}
输出:3 2 1 0
8, Range新增至四种类型
Range
CountableRange
ClosedRange
CountableClosedRange
不同的表达式会生成不同的Range
var countableRange = 0..<20 'CountableRange(0..<20)' var countableClosedRange = 0...20 'CountableClosedRange(0...20)'
9, Swift3.0 Collection 新增 index(_:)系列方法
Index的successor(), predecessor(), advancedBy(_:), advancedBy(_:limit:), or distanceTo(_:)方法被移除,这些操作被移动到Collection
myIndex.successor() => myCollection.index(after: myIndex)
myIndex.predecessor() => myCollection.index(before: myIndex)
myIndex.advance(by: …) => myCollection.index(myIndex, offsetBy: …)
10, iOS10 UIStatusBar过期
如果你需要操作UIStatusBar,在iOS10需要改为
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
11, iOS10 UICollectionView 性能优化
在iOS10 UICollectionView 最大的改变是增加了Pre-Fetching(预加载),
如果你翻看UICollectionView的最新API你可以发现新增了如下属性:
@property (nonatomic, weak, nullable) id<UICollectionViewDataSourcePrefetching> prefetchDataSource @property (nonatomic, getter=isPrefetchingEnabled) BOOL
在iOS10 Pre-Fetching 是默认开启的,如果出于某些原因你不想开启Pre-Fetching,可以通过如下设置禁用:
collectionView.isPrefetchingEnabled = false
UICollectionViewDataSourcePrefetching协议定义如下:
@protocol UICollectionViewDataSourcePrefetching <NSObject>
@required
// indexPaths are 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 be a subset of the previous call to -collectionView:prefetchItemsAtIndexPaths:
- (void)collectionView:(UICollectionView *)collectionView cancelPrefetchingForItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_AVAILABLE_IOS(10_0); @end
12, iOS10 UITableView 性能优化
和UICollectionView一样UITableView也增加了Pre-Fetching技术,UITableView新增了如下属性:
@property (nonatomic, weak) id<UITableViewDataSourcePrefetching> prefetchDataSource NS_AVAILABLE_IOS(10_0);
奇怪的是UITableView并没有找到isPrefetchingEnabled属性的定义
13,iOS10 UIScrollView 新增 refreshControl 属性
UIScrollView新增了refreshControl属性
@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(10_0) __TVOS_PROHIBITED;
这意味着UICollectionView和UITableView都支持refresh功能了。
我们也可以脱离UITableViewController使用UIRefreshControl了。
14, Swif3.0 新增作用域访问级别 fileprivate
目前有如下访问级别:
- 公开(public)
- 内部(internal)
- 文件外私有(fileprivate)
- 私有(private)
15,Swift3.0 允许关键字作为参数标签
Swift3.0开始我们将能使用除inout var let关键字作为参数标签
// Swift 3 calling with argument label:
calculateRevenue(for sales: numberOfCopies,
in .dollars) // Swift 3 declaring with argument label:
calculateRevenue(for sales: Int,
in currency: Currency) func touchesMatching(phase: NSTouchPhase, in view: NSView?) -> Set<NSTouch>
如果你坚持要使用inout var let关键字可以使用 `` 包裹参数标签
func addParameter(name: String, `inout`: Bool)
iOS 10 / Swift 3.0 / XCode 8 总结的更多相关文章
- iOS开发swift语法0基础篇—————(swift技术交流群:361513739)
iOS开发之swift语法0基础篇:点击打开链接 swift技术交流QQ群361513739
- iOS之Xcode 8.0真机调试运行:This ** is running iOS 10.1.1 (14B100), which may not be supported
2016年10月份 苹果升级了iOS系统为10.1,xcode 8.0 运行会提示: This iPhone 5 (Model A1429) is running iOS 10.1.1 (14B100 ...
- iOS开发系列--Swift 3.0
概述 从写第一篇Swift文章的时候到现在Swift已经从1.2发展到了今天的3.0,这期间由于Swift目前还在发展阶段并不能向下兼容,因此第一篇文章中的部分代码在当前的Xcode环境中已经无法运行 ...
- 使用 Swift 在 iOS 10 中集成 Siri —— SiriKit 教程
下载 Xcode 8,配置 iOS 10 和 Swift 3 (可选)通过命令行编译 除 非你想使用命令行编译,使用 Swift 3.0 的工具链并不需要对项目做任何改变.如果你想的话,打开 Xcod ...
- iOS 10.0 更新点(开发者视角)
html, body {overflow-x: initial !important;}html { font-size: 14px; } body { margin: 0px; padding: 0 ...
- iOS 10、Xcode 8 遇到部分问题解决记录
今天把iphone 6 升级到ios10 后,用Xcode 7进行真机调试的时候提示: Could not find Developer Disk Image 果断准备升级到Xcode 8 .但是想保 ...
- 在 iOS 10.0 之后, App 要调用手机相机与相簿应注意的事项
iOS 的 SDK 每一年至少都会有一次大改版,从 2009 到 2016 年,版号已经到了第 10 版了,很轻易的就追上了 Mac OSX. 每一次的大改版都会有不少新的功能或新的规范,在 iOS ...
- 【转1】Appium 1.6.3 在Xcode 8, iOS 10.2(模拟器)测试环境搭建 经验总结
Appium 1.6.3 在Xcode 8, iOS 10.2(模拟器)测试环境搭建 经验总结 关于 Appium 1.6.3 在Xcode 8, 10.2 的iOS模拟器上的问题很多,本人也差点放弃 ...
- Xcode 8.0 新特性 & Swift 3.0 增加的变动
从 Xcode 8.0 开始,目前所有的插件都无法工作! NSLog 无法输出 -- 此bug等待正式版本... Xcode 提供了文档注释快捷键option + cmd + / 但是要把系统升级到1 ...
随机推荐
- JavaEE:Eclipse开发工具的相关使用和XML技术
Eclipse开发工具的知识点1.工程的属性(properties)1)Text file encoding 工程编码(在导入其他工程时,注意编码类型一致)2)Java build path设置cl ...
- hdu-4471-Homework-矩阵快速幂+优化加速
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4471 题目意思: 求f(n). 当n为特殊点nk时 解题思路: 当x不为特殊点时,直接用基本的矩阵快 ...
- 34. LotusScript中的错误处理程序
错误处理程序是所有严肃的程序的必要部分.但是在Lotus Notes开发中,很多程序员编写LotusScript代码时,并没有写专门的错误处理代码的习惯.这能够行得通,主要是因为LotusScript ...
- Android中检测软键盘的弹出和关闭
Android系统并没有提供明显的API来监听软键盘的弹出和关闭,但是在某些情况下我们还是有办法来检测软键盘的弹出和关闭. 从StackOverflow找到了一个不错的方法.但是这种只适用于在mani ...
- tampermonkey,采用js解析自定义脚本,实现网页列表数据采集分析
最近一直在做数据采集的事情,目的是使用java开发一套分析指定采集规则,模拟用户动作做数据提取.因此定义了一套动作脚本,open,click,get,list,opentab,closetab...j ...
- 简单的遮罩层效果,user登陆显示效果
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- .NET基础——循环、枚举
1. 循环结构 3种循环语句:while.do-while.for 面对循环我们应当注意: 1. 循环在做什么?(重复做的事情——也就是循环体的内容) 2. 循环的终止条件是什么?(循环条件) 3种循 ...
- iOS开源项目周报0112
由OpenDigg 出品的iOS开源项目周报第五期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. GD ...
- virtualbox 中的linux 共享文件
首先要安装VirtualBox的增强版功能(VBoxGuestAdditions) 在 设备--->安装增强版功能----->运行,重启电脑. 出现这个问题,看看安装增强功能的时候,有没有 ...
- 数娱科技:借助VR技术可让你了解自己的大脑
你可能很好奇自己的大脑,如果你是一个脑部病患,可能更想了解下自己的大脑.好消息是,脑机接口让这个想法成为可能. 在上周六,AR/VR科技公司广州数娱科技发布了联合5家单位共同研发的"VR人脑 ...