Swift入门一:记Swift与Oc的一些语言区别

来源:互联网 发布:淘宝店需要营业执照 编辑:程序博客网 时间:2024/05/18 22:15

1:但是初步看Swift,发现Swift只有var 和 let两种 

2:问度娘发现Swift中var表示变量,let表示常量

2. Swift写一个string值,不需要@也不需要;(分号), 如var str = “hello,world”

3:Swift输出函数用println(str)str是“hello,world”

4:Swift填icon只需要一部,打开Assets.xcassets 里面的icon ,把对于图片尺寸放上去,运行!,ok!

5:以下是转载过来的

  1. /** 
  2. * 元组 java中map的马甲,先这么理解吧 
  3. */  
  4. let http404Error = (404"Not Found")  
  5. let (statusCode, statusMessage) = http404Error  
  6. println("The status code is \(statusCode)")  
  7. // 输出 "The status code is 404"  
  8. println("The status message is \(statusMessage)")  
  9. // 输出 "The status message is Not Found"  
  10.   
  11. let (justTheStatusCode, _) = http404Error  
  12. println("The status code is \(justTheStatusCode)")  
  13. // 输出 "The status code is 404"  只需要一部分元组值,分解的时候可以把要忽略的部分用下划线(_)标记  
  14.   
  15.   
  16. println("The status code is \(http404Error.0)")  
  17. // 输出 "The status code is 404" 下标方式取值  
  18. println("The status message is \(http404Error.1)")  
  19. // 输出 "The status message is Not Found" 下标方式取值  
  20. let http200Status = (statusCode: 200, description"OK"//凌乱了, 居然可以这样写, 这是map<String , Object> 先这么理解吧。  

0 0