
Daniel 2017-03-23 13:20
苹果Mac Pro垃圾桶 最低配的ME253CH
回复:61 查看:32735

Swift 2017-04-30 10:37
Equatable我是从 [The Swift Programming Language (Swift 3.0)] 中文版里看到的,链接:
泛型 - Swift 3.0 教程
Sequence的介绍我也没有看到,是我自己根据字面意思做的解释。
Sequence的介绍我也没有看到,是我自己根据字面意思做的解释。

Daniel 2017-05-07 01:02
Currently I am studying the 3rd book "Swift Programming", I think it is a quite useful book.
I can send electronic copies of the book to you if you want (send me an e-mail).
dkychang@qq.com

Swift 2017-05-08 00:31
已收到,谢谢!

Daniel 2017-05-08 11:48
I have two iOS books (front pages shown before) which I have not yet started reading because I have no Mac machine yet.
Are you interested in having their electronic copies?
dkychang@qq.com
Are you interested in having their electronic copies?
dkychang@qq.com

Swift 2017-05-08 22:53
谢谢,暂时不需要了,全英文的看着有点吃力,我还是先看看中文视频。

Daniel 2017-05-09 16:49
同你相反, 我看中文的计算机书有点吃力.

Satlantisy 2017-05-09 21:17
买个macbook air或者mini最便宜的也够用了 网页版没有实时显示效果

Satlantisy 2017-05-09 21:20
@Daniel
I have two iOS books (front pages shown before) which I have not yet started reading because I have no Mac machine yet.
Are you interested in having their electronic copies?
dkychang@qq.com
Are you interested in having their electronic copies?
dkychang@qq.com
I appreciate for your help!
szp895@gmail.com

Swift 2017-05-09 23:35
@Daniel
同你相反, 我看中文的计算机书有点吃力.

Swift 2017-05-09 23:38
@Satlantisy
买个macbook air或者mini最便宜的也够用了 网页版没有实时显示效果

Daniel 2017-05-13 07:42
@Swift
已收到,谢谢!
Especially the 2nd init of the class definition (like a recursive definition?)
fileprivate class IntArrayBuffer { var storage: [Int] init() { storage = [] } init(buffer: IntArrayBuffer) { storage = buffer.storage } } struct IntArray { private var buffer: IntArrayBuffer init() { buffer = IntArrayBuffer() } func describe() { print(buffer.storage) } }

Swift 2017-05-13 23:40
@Daniel
//两个init是独立的,只是多了一个方式来创建IntArrayBuffer fileprivate class IntArrayBuffer { var storage: [Int] //这个没有传递参数,把storage初始化为空数组。 init() { storage = [] } //这个有一个IntArrayBuffer类型的参数,storage初始化为buffer.storage init(buffer: IntArrayBuffer) { storage = buffer.storage } } struct IntArray { private var buffer: IntArrayBuffer init() { buffer = IntArrayBuffer() } func describe() { print(buffer.storage) } }下面的代码展示如何使用IntArrayBuffer
private var bufferA = IntArrayBuffer() bufferA.storage = [1,2,3] //把bufferA.storage复制到bufferB.storage private var bufferB = IntArrayBuffer(buffer: bufferA) print(bufferB.storage) //print [1,2,3]

Daniel 2017-05-16 20:34
@Swift
已收到,谢谢!
Chapter 24 (from Listing 24.7 until the chapter end) is not easy to understand even I saw the examples working.
.

Swift 2017-05-17 17:37
@Daniel Thanks, Please send to me.

Daniel 2017-05-24 15:00
Do you understand the purpose of the keyword
let in the following code? if you do, please explain.
I know that the code can not even be compiled without the two let.
I know that the code can not even be compiled without the two let.
enum ShapeDimensions { // point has no associated value - it is dimensionless case point // square's associated value is the length of one side case square(side: Double) // rectangle's associated value defines its width and height case rectangle(width: Double, height: Double) func area() -> Double { switch self { case ShapeDimensions.point: return 0 case let ShapeDimensions.square(side: side): return side * side case let ShapeDimensions.rectangle(width: w, height: h): return w * h } } } var squareShape = ShapeDimensions.square(side: 10.0) var rectShape = ShapeDimensions.rectangle(width: 5.0, height: 10.0) var pointShape = ShapeDimensions.point print("square's area = \(squareShape.area())") print("rectangle's area = \(rectShape.area())") print("point's area = \(pointShape.area())")

Daniel 2017-05-26 19:11
Why
deinit is called for the second assignment in the following code?
struct Town { } class Monster { } class Zombie: Monster { var walksWithLimp: Bool init(limp: Bool, town: Town?){ walksWithLimp = limp } convenience init(limp: Bool) { self.init(limp: limp, town: nil) } deinit { print("ZZZZombie is no longer with us.") } } var convenientZombie = Zombie(limp: true) convenientZombie = Zombie(limp: true)

Daniel 2017-05-26 20:52
The above code can be simplified as follows.
Why deinit is executed for the second assignment?
Why deinit is executed for the second assignment?
class Zombie { var walksWithLimp: Bool init(limp: Bool){ walksWithLimp = limp } deinit { print("ZZZZombie is no longer with us.") } } var convenientZombie = Zombie(limp: true) convenientZombie = Zombie(limp: true)

Daniel 2017-05-26 21:29
I understand
deinit
now:
In the above code, when the 2nd assignment (line 15) is executed, the memory allocated for the Right Hand Side of the 1st assignment (line 13) is no longer used, hence the system will automatically call deinit to clean up the memory for us.
In the above code, when the 2nd assignment (line 15) is executed, the memory allocated for the Right Hand Side of the 1st assignment (line 13) is no longer used, hence the system will automatically call deinit to clean up the memory for us.

Swift 2017-05-27 11:50
@Daniel 关于let,刚开始我也看得不太明白,后来看了下官方文档枚举章节,知道这个let是把后面的参数定义为常量的意思,但是你这个例子和
官方文档里的有些区别,所以我做了一下修改:
enum ShapeDimensions { case point //原文:case square(side: Double) //去掉了side case square(Double) //原文:case rectangle(width: Double, height: Double) //去掉了width,height case rectangle(Double, Double) func area() -> Double { switch self { case ShapeDimensions.point: return 0 //原文:case let ShapeDimensions.square(side: side): //原文中的side: side,2个side感觉有两个变量名似的,看起来不好理解。 //因为最上面是这样写的:case square(side: Double) //所以这里我觉得应该这样写:case let ShapeDimensions.square(side: Double): //但是这样写编译不通过 //通过下面这样的写法就好理解为什么加let了,因为side是个常量名,不能无中生有,必须用let定义出来。当然let也可以改成var case let ShapeDimensions.square(side): return side * side //原文:case let ShapeDimensions.rectangle(width: w, height: h): //let加在case后面是这句的简写:case ShapeDimensions.rectangle(let w, let h): case let ShapeDimensions.rectangle(w, h): return w * h } } } var squareShape = ShapeDimensions.square(10.0) //原文:square(side: 10.0) var rectShape = ShapeDimensions.rectangle(5.0, 10.0) //原文:rectangle(width: 5.0, height: 10.0) var pointShape = ShapeDimensions.point print("square's area = \(squareShape.area())") print("rectangle's area = \(rectShape.area())") print("point's area = \(pointShape.area())")

Daniel 2017-05-31 10:10
我买的第3本Swift的书{Swift Programming 2nd ed.]看了二遍,还有许多高级一些的内容不懂, 现在又买了第4本Swift的书[Advanced Swift3],有中文及英文版本,现在只收到中文版的,还没有收到英文版的. 在我年底或明年初买到苹果计算机前只能学Swift编程而不能开始字习iOS编程.
