-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
79 lines (64 loc) · 5.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Jiangjiefs.GitHub.io by JiangJieFS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
</head>
<body>
<section class="page-header">
<h1 class="project-name">Jiangjiefs.GitHub.io</h1>
<h2 class="project-tagline"></h2>
</section>
<section class="main-content">
<h1>
<a id="swift语言优缺点小结" class="anchor" href="#swift%E8%AF%AD%E8%A8%80%E4%BC%98%E7%BC%BA%E7%82%B9%E5%B0%8F%E7%BB%93" aria-hidden="true"><span class="octicon octicon-link"></span></a>swift语言优缺点小结</h1>
<h2>
<a id="优点主要参考这篇总结" class="anchor" href="#%E4%BC%98%E7%82%B9%E4%B8%BB%E8%A6%81%E5%8F%82%E8%80%83%E8%BF%99%E7%AF%87%E6%80%BB%E7%BB%93" aria-hidden="true"><span class="octicon octicon-link"></span></a>优点(<a href="http://programmers.stackexchange.com/questions/242816/how-can-swift-be-so-much-faster-than-objective-c-in-these-comparisons">主要参考这篇总结</a>):</h2>
<h3>
<a id="类型安全" class="anchor" href="#%E7%B1%BB%E5%9E%8B%E5%AE%89%E5%85%A8" aria-hidden="true"><span class="octicon octicon-link"></span></a>类型安全</h3>
<ul>
<li>Swift是一门类型安全语言,类型安全语言需要代码里值的类型非常明确。如果你的代码中有部分值需要String类型,你就不能错误地传递Int。鉴于Swift的类型安全,编译代码时,Swift会执行类型检查并将任何类型不匹配的地方标记为错误,使你在开发当中尽可能早的捕获并修正错误。
###简洁、易读</li>
<li>简洁是对开发者来说最主要的特性,很多特性都会帮助减少代码量</li>
<li>网上有说oc代码长度是swift四倍的,也有说五倍的
###无需管理内存</li>
<li>oc中在调用底层api比如Core Graphics,或者写面向过程的代码时仍需要手动释放内存
###易维护</li>
<li>没有头文件
###速度快</li>
<li>
<a href="http://programmers.stackexchange.com/questions/242816/how-can-swift-be-so-much-faster-than-objective-c-in-these-comparisons">swift为何比oc快</a>
###命名空间</li>
<li>在 Swift 中,由于可以使用命名空间了,即使是名字相同的类型,只要是来自不同的命名空间的话,都是可以和平共处的。和 C# 这样的显式在文件中指定命名空间的做法不同,Swift 的命名空间是基于 module 而不是在代码中显式地指明,每个 module 代表了 Swift 中的一个命名空间。也就是说,<strong>同一个 target 里的类型名称是不能相同的</strong>。在我们进行 app 开发时,默认添加到 app 的主 target 的内容都是处于同一个命名空间中的,我们可以通过创建 Cocoa (Touch) Framework 的 target 的方法来新建一个 module,这样我们就可以在两个不同的 target 中添加同样名字的类型了。
###闭包和高阶函数</li>
<li>
<a href="http://www.cocoachina.com/swift/20150619/12173.html">Swift一大特性便是使用简洁的头等函数/闭包语法代替了复杂的blocks语法</a>。</li>
<li>不仅写起来更简介,执行也更高效
###playground即时预览</li>
<li>这个方便学习swift,所见即所得</li>
</ul>
<hr>
<h2>
<a id="缺点" class="anchor" href="#%E7%BC%BA%E7%82%B9" aria-hidden="true"><span class="octicon octicon-link"></span></a>缺点:</h2>
<h3>
<a id="更新快" class="anchor" href="#%E6%9B%B4%E6%96%B0%E5%BF%AB" aria-hidden="true"><span class="octicon octicon-link"></span></a>更新快</h3>
<ul>
<li>Swift更新太快,还不稳定,给推广带来了阻碍,所以诸多开发者更愿意再等一段时间。Scott Logic软件开发公司的技术总监Colin Eberhardt说,Swift频繁更新使他不得不频繁调整自己的代码。他说:“做产品代码的,肯定不愿意用Swift。”目前苹果还不愿回应这个问题。</li>
<li>比如wwdc2015带来的swift 2.0版本对之前的语法有诸多不兼容,不过xcode也提供了转换工具来帮助解决语法升级的问题</li>
</ul>
<h3>
<a id="混合oc和swift包会变大" class="anchor" href="#%E6%B7%B7%E5%90%88oc%E5%92%8Cswift%E5%8C%85%E4%BC%9A%E5%8F%98%E5%A4%A7" aria-hidden="true"><span class="octicon octicon-link"></span></a>混合oc和swift包会变大</h3>
<ul>
<li>比如在我们的工程中加入了swift代码之后编译完的程序包右17m变到23m</li>
</ul>
<footer class="site-footer">
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span>
</footer>
</section>
</body>
</html>