Swift 特辑
Leexianke
iOS开发
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Swift 2.0 之map 与 zip
map 与 zip 并非Swift首创,不过对于熟悉OC的ios开发者来说,还是比较陌生的。其实不难理解,zip是把一组待操作对象打包起来,可以理解成array的array。而map所做的是把这些对象依次执行操作,有些流水线的味道。下面是一个常见的例子: zip([leftHoop, rightHoop, hoop, hoop], offsets).map({ (item, offset原创 2015-10-03 13:23:48 · 1239 阅读 · 0 评论 -
Core Data异常: model used to open the store is incompatible with the one used to create the store
出现这种异常的原因非常简单,你修改了model中的属性,而且已经本地化缓存了一部分数据,所以导致此错误。 最简单的解决方案就是直接卸载APP,可以清除缓存。 最佳的解决方案是设置Core Data的版本,具体步骤如下: (1)在项目导航栏中,选择Data Model文件; (2)在File inspector 面板窗口,找到Versioned原创 2015-10-07 20:58:37 · 832 阅读 · 0 评论 -
swift is only available on iOS 9.0 or newer 报错
is only available on iOS 9.0 or newer 出现此报错的原因是你使用了只适用于新版本的API,解决方法十分简单,先检查平台 if #available(iOS 9.0, *) { //把出现报错的特性在这里处理 } else { //ios9以下的如需处理在这里用低版本API处理 }原创 2015-10-11 15:09:44 · 5068 阅读 · 0 评论 -
swift2.0 之 关键字
正如所有语言一样,swift中也存在大量的关键字用于区别不同的功能代码,本文主要介绍swift的关键字的含义及注意点。本文目录: 1.var 与 let 2.override,private与public 3. 4. 5. 6.一 var 与 let swift中极度精简变量的声明,var表示可变,let表示不可变。而变量原创 2015-09-23 21:10:09 · 541 阅读 · 0 评论 -
Swift 尾随闭包(Trailing closure syntax) 的使用
func seporateString(string: String, handler: (str1: String, str2: String) -> Void) -> Bool { if string.startIndex endIndex.advancedBy(-2) { let str1 = string.substringToIndex(s原创 2015-12-30 18:44:18 · 1759 阅读 · 0 评论 -
Swift 等同性判断 Hashable Equatable ==
func ==(lhs: Testhash, rhs: Testhash) -> Bool { return lhs.hashValue == rhs.hashValue}class Testhash: Hashable { var hashValue: Int { get { return原创 2016-01-01 14:51:33 · 1479 阅读 · 0 评论
分享