Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties in Swift #127

Merged
merged 6 commits into from Sep 18, 2018
Merged

Properties in Swift #127

merged 6 commits into from Sep 18, 2018

Conversation

sunnyyoung
Copy link
Member

@sunnyyoung sunnyyoung changed the title Add Swift 中的属性.md Properties in Swift Sep 9, 2018
Copy link
Member

@LinusLing LinusLing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

翻译完毕后,建议对译文进行通读,避免一些“指”误。
有两处是 not only... but also 的简略用法,可以一起探讨一下。

Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved

## 具有私有 Setter 的公共属性

正如我在[本文](http://www.thomashanning.com/public-properties-with-private-setters/)中更详细说明的那样,这是一种常见的情况,你不想提供一个公共的 getter,而是提供一个私有的 setter。这是封装的基本原则。通过这样只有类本身可以操作该属性,但仍可从类外部访问读取。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原译文:
正如我在本文中更详细说明的那样,这是一种常见的情况,你不想提供一个公共的 getter,而是提供一个私有的 setter。这是封装的基本原则。通过这样只有类本身可以操作该属性,但仍可从类外部访问读取。

建议:
正如本人另一篇文章中提出的一种常见的情况,你希望提供一个只有类内部能 setter,而外部仍然能 getter 的属性。这是封装的基本原则。至此,不仅类本身可以操作该属性,类的外部仍然能访问和读取它。

Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
Thomas Hanning/Swift 中的属性.md Outdated Show resolved Hide resolved
@OneeMe
Copy link

OneeMe commented Sep 18, 2018

@OneeMe OneeMe merged commit d709b2b into SwiftGGTeam:master Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants