swift学习_xcode基础学习

android L已经在开发大会上公布了, 技术得跟上时代的潮流, 一心想在移动互联网中发展,只好努力学习 html+ js  ,  oc ! 服务器运维我就不写了,就算是自己的生活记录。android 说真心话, 一直想写,结果发现自己很喜欢写得连续点,就像仙剑一样, 应该是能让人回味的那种,文笔不好 , 就先这些基础开始练习吧。 

发呆中。。。。。

上一个教程中 xcode6  安装后,打开xcode开始界面,我突然发现 get start playground , 一直在犹豫他是神马。。。。

点击get start playground 之后,界面有大惊喜,这个是html 常会出现的实时页面,  记得用blog写md 语法的时候 ,就是这样的页面。。。。



        

好吧, var  js的节奏啊 !!  瞬间激动了, 难道oc和js 合体了, swift果然是神器可怜

        接下来部分代码

// Playground - noun: a place where people can play

import Cocoa

var str = "Hello, playground" //变量
var x = 0.0, y = 0.0, z = 0.0
let numInt = 10 //常量
/**
*多行注释
*/
println(str) //输出函数
println(numInt)
println("str is \(str) num is \(numInt)")


/**
*需要注意Double
*/
let anotherPi = 3 + 0.14159
// anotherPi 会被推测为 Double 类型
let decimalInteger = 17
let binaryInteger = 0b10001       // 二进制的17
let octalInteger = 0o21           // 八进制的17
let hexadecimalInteger = 0x11     // 十六进制的17 很喜欢0x ,让我想起了做游戏外挂时的痛苦,读取内存基址

/**
* 元组 java中map的马甲,先这么理解吧
*/
let http404Error = (404, "Not Found")
let (statusCode, statusMessage) = http404Error
println("The status code is \(statusCode)")
// 输出 "The status code is 404"
println("The status message is \(statusMessage)")
// 输出 "The status message is Not Found"

let (justTheStatusCode, _) = http404Error
println("The status code is \(justTheStatusCode)")
// 输出 "The status code is 404"  只需要一部分元组值,分解的时候可以把要忽略的部分用下划线(_)标记


println("The status code is \(http404Error.0)")
// 输出 "The status code is 404" 下标方式取值
println("The status message is \(http404Error.1)")
// 输出 "The status message is Not Found" 下标方式取值
let http200Status = (statusCode: 200, description: "OK") //凌乱了, 居然可以这样写, 这是map<String , Object> 先这么理解吧。















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值