为了账号安全,请及时绑定邮箱和手机立即绑定
  • 集合:去重且无序,数组有序列表
    查看全部
    2 采集 收起 来源:Swift2.0集合

    2016-08-16

  • min = numbers.minElement() max = numbers.maxElement()
    查看全部
  • 大写的服
    查看全部
  • 闭包可以理解为一个匿名函数,所以 1.不需要函数名 2.不需要有外部参数名 3.闭包的声明最后要加in关键字 4.闭包使用{}包裹
    查看全部
  • 然而3.X中已经不支持if where了,变成用“,”分割了,更加简洁。 swift 3.0 中,似乎第二个解包也需要写上 let 。
    查看全部
  • 最近一句显示视图已改为:XCPlaygroundLiveViewRepresentation.View(showView)
    查看全部
  • func tier1MailFeeBy(weight:Int) -> Int { return 1 * weight } func tier2MailFeeBy(weight:Int) -> Int { return 3 * weight } func chooseMailFeeCalculationBy(weight: Int) -> (Int) -> Int { return weight <= 10 ? tier1MailFeeBy : tier2MailFeeBy } func feeBy(unitPrice: Int, weight: Int) ->Int { let maiFeeByWeight = chooseMailFeeCalculationBy(weight) return maiFeeByWeight(weight) + unitPrice * weight } var price = 20 var weight = 15 feeBy(price, weight: weight)
    查看全部
  • import UIKit //默认参数 func sayHelloTo(name: String , withGreetingWord greeting: String = "Hello",mpubctuation: String = "!") -> String {<br>   return "\(greeting),\(name)\(mpubctuation)" } sayHelloTo("Playground", withGreetingWord: "Hello")<br> sayHelloTo("bobob") sayHelloTo("imooc", mpubctuation: "!!!") //可变参数 func mean(numbers: Double...) -> Double {   var sum: Double = 0   for number in numbers {     sum += number   }   return sum / Double(numbers.count) } mean(1,2) mean(12,13,45) func sayHelloTo1(names: String ... , withGreetingWord greeting: String,mpubctuation: String){   for name in names {     print("\(greeting), \(name)\(mpubctuation)")   } } sayHelloTo1("A","B","C" , withGreetingWord:"Hi" , mpubctuation: "!!")
    查看全部
  • //一般第一个参数的外部参数名包含在函数名中;withGreetingWord为外部参数名;greeting为内部参数名 func sayHelloTo( name: String , withGreetingWord greeting: String ) -> String {    return "\(name),\(greeting)" } //sayHelloTo("Playground", greeting: "Hello")   sayHelloTo("Playground", withGreetingWord: "Hello") //计算乘积 func mutipleOf( num1: Int , and num2: Int) -> Int {    return num1 * num2 } mutipleOf(4, and: 2) //如果我们只想显示两个值字段 func mutiply( num1: Int , _ num2: Int) -> Int {    return num1 * num2 } mutiply(5, 10)
    查看全部
  • 1.集合无序 2.集合去重 (定义集合,数组转集合,集合基本操作,集合的判断)
    查看全部
    1 采集 收起 来源:Swift2.0集合

    2016-07-18

  • 集合的特点:唯一不重复 、无序、(查重操作)方法.first指随机取出集合中的一个元素
    查看全部
    1 采集 收起 来源:Swift2.0集合

    2016-07-15

  • // 强制解包必须确认不为空 errorCode! if errorCode != nil { code + errorCode! } // 解包并使用,errorCode只限在花括号中 if let unWrapedErrorCode = errorCode { "code"+ unWrapedErrorCode } if let errorCode = errorCode { "code" + errorCode } else { "no error" } // 多个解包 if let errorCode = errorCode , errorMsg = errorMsg { ... } // 多个解包 包含多个条件处理 if let errorCode = errorCode , errorMsg = errorMsg where errorCode =="404" { ... }
    查看全部
  • errorMsg?.upperCaseString 尝试解包 errorMsg!.upperCaseString 确定解包(确保不为空,否则报错)
    查看全部
  • func tier1MailFeeBy(weight:Int) -> Int { return 1 * weight } func tier2MailFeeBy(weight:Int) -> Int { return 3 * weight } func feeBy(unitPrice: Int, weight: Int) -> Int { func chooseMailFeeCalculationBy(weight: Int) -> (Int) -> Int { return weight <= 10 ? tier1MailFeeBy : tier2MailFeeBy } let maiFeeByWeight = chooseMailFeeCalculationBy(weight) return maiFeeByWeight(weight) + unitPrice * weight } var price = 20 var weight = 15 feeBy(price, weight: weight)
    查看全部
  • 简洁语法
    查看全部
首页上一页1234567下一页尾页

举报

0/150
提交
取消
课程须知
本课程适合至少有一门编程语言基础的同学用于学习Swift语言。也适合在学习使用swift进行iOS开发的过程中,遇到不清楚的swift语言问题随时查询。
老师告诉你能学到什么?
这是《玩儿转swift2.0》系列课程的第二季。通过整个系列课程的学习,大家可以全面、深入地了解swift的语法与语言特性,理解swift的设计原则和理念,同时对面向对象、面向协议、面向函数等思想有一定的了解,对swift语言的掌握达到中等偏上的水平。

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!