IOS开发-Swift新语言初见
Safe
Swift pairs increased type safety with type inference, restricts direct access to pointers, and automatically manages memory—making it easy to create secure, stable software.
funcconfigureLabels(labels:
UILabel[]) {
letlabelTextColor =
UIColor.greenColor()forlabel
in
labels {//
label inferred to be UILabellabel.textColor
=
labelTextColor}}
Modern
Swift includes optionals, generics, tuples, and other modern language features. Inspired by and improving upon Objective-C, Swift code feels natural to read and write.
letcities = ["London",
"San Francisco",
"Tokyo",
"Barcelona",
"Sydney"]letsortedCities =
sort(cities)
{
$0 <
$1 }iflet
indexOfLondon =
find(sortedCities,"London") {
println("London
is city number \(indexOfLondon
+
1)
in the list")}
Powerful
Take advantage of powerful pattern matching in Swift to write simple, expressive code. Format strings naturally with string interpolation. Use frameworks like Foundation and UIKit directly from Swift.
letsize = (20,
40)
switchsize {
caselet (width,
height)
where
width ==
height:println("square
with sides \(width)")case
(1..10,1..10):
println("small
rectangle")caselet (width,
height):
println("rectangle
with width \(width)
and height \(height)")}
Interactive
Use playgrounds to experiment with new technologies, analyze problems, and prototype user interfaces.

Fast
The Swift compiler applies advanced code analysis to tune your code for performance, letting you focus on writing great apps instead of on implementing complex optimizations.
IOS开发-Swift新语言初见的更多相关文章
- iOS开发Swift篇—(二)变量和常量
iOS开发Swift篇—(二)变量和常量 一.语言的性能 (1)根据WWDC的展示 在进行复杂对象排序时Objective-C的性能是Python的2.8倍,Swift的性能是Python的3.9倍 ...
- 李洪强iOS开发Swift篇—02_变量和常量
李洪强iOS开发Swift篇—02_变量和常量 一.语言的性能 (1)根据WWDC的展示 在进行复杂对象排序时Objective-C的性能是Python的2.8倍,Swift的性能是Python的3. ...
- iOS开发系列--C语言之基础知识
概览 当前移动开发的趋势已经势不可挡,这个系列希望浅谈一下个人对IOS开发的一些见解,这个IOS系列计划从几个角度去说IOS开发: C语言 OC基础 IOS开发(iphone/ipad) Swift ...
- iOS开发Swift篇—(一)简单介绍
iOS开发Swift篇—简单介绍 一.简介 Swift是苹果于2014年WWDC(苹果开发者大会)发布的全新编程语言 Swift在天朝译为“雨燕”,是它的LOGO 是一只燕子,跟Objective-C ...
- iOS开发Swift篇—(三)字符串和数据类型
iOS开发Swift篇—(三)字符串和数据类型 一.字符串 字符串是String类型的数据,用双引号""包住文字内容 let website = "http://www ...
- iOS开发Swift篇—(四)运算符
iOS开发Swift篇—(四)运算符 一.运算符 1.Swift所支持的部分运算符有以下一些 赋值运算符:= 复合赋值运算符:+=.-= 算术运算符:+.-.*./ 求余运算符:% 自增.自减运算符: ...
- iOS开发Swift篇—(六)流程控制
iOS开发Swift篇—(六)流程控制 一.swift中的流程控制 Swift支持的流程结构如下: 循环结构:for.for-in.while.do-while 选择结构:if.switch 注意:这 ...
- iOS开发Swift篇—(九)属性
iOS开发Swift篇—(九)属性 一.类的定义 Swift与Objective-C定义类的区别 Objective-C:一般需要2个文件,1个.h声明文件和1个.m实现文件 Swift:只需要1个. ...
- iOS开发Swift篇—简单介绍
iOS开发Swift篇—简单介绍 一.简介 Swift是苹果于2014年WWDC(苹果开发者大会)发布的全新编程语言 Swift在天朝译为“雨燕”,是它的LOGO 是一只燕子,跟Objective-C ...
随机推荐
- ZOJ 2412 Farm Irrigation(DFS 条件通讯块)
意甲冠军 两个农田管内可直接连接到壳体 他们将能够共享一个水源 有11种农田 管道的位置高于一定 一个农田矩阵 问至少须要多少水源 DFS的连通块问题 两个相邻农田的管道能够直接连接的 ...
- GIF/PNG/JPG和WEBP/base64/apng图片优点和缺点整理(转)
如何获取图片对应的base64字符串呢? 1:使用代码获取: 运行下面代码 var reader = new FileReader(), htmlImage; reader.onload = func ...
- Direct3D 使用质地
关于使用质地 1 创建纹理 2 纹理寻址模式 3 纹理过滤 1 创建纹理 <1> D3DXCreateTexture功能 创建一个空的纹理. HRESULT D3DXCreateText ...
- iOS 要定义自己的导航栏button样式Button Image 执行出彩是不一样的与原来的颜色 -解
在相机闪光灯,在导航栏中自己定义"闪"样式.点击变换的图像期望,但一直没有变化.原来是该条款的Global Tint颜色.因此,系统会自己主动改变图片的颜色Global Tint颜 ...
- Codeforces Round #261 (Div. 2) E. Pashmak and Graph DP
http://codeforces.com/contest/459/problem/E 不明确的是我的代码为啥AC不了,我的是记录we[i]以i为结尾的点的最大权值得边,然后wa在第35 36组数据 ...
- ExtJS学习笔记:定义extjs类别
类的定义 Ext.define('Cookbook.Vehicle', { Manufacturer: 'Aston Martin', Model: 'Vanquish', getDetails: f ...
- WPF学习(11)2D绘图
本篇我们来学习WPF的绘图,在2D绘图中主要有这么几个重要的类:Drawing.Visual和Shape,顺便讲下Brush和BitmapEffect. 1 2D绘图 1.1Drawing类 Draw ...
- 移动端 常见问题整理 iOS下的 Fixed + Input 调用键盘的时候fixed无效问题解决方案
使用iScroll时,input等不能输入内容的解决方法 <script> function allowFormsInIscroll(){ [].slice.call(document.q ...
- [Visual Studio]透过Visual Studio 2012的选择性贴上将XML与JSON直接转成对应的类别
原文:[Visual Studio]透过Visual Studio 2012的选择性贴上将XML与JSON直接转成对应的类别 在开发专案时若碰到要串接服务或是他人的API,常常避免不了都要面对XML或 ...
- dojo加载树错误
1.错误叙述性说明 error loading undefined children. TypeError:this._arrayOfTopLevelItems is undefied. ...