Andrew Bancroft 4/22/2015

3 Nuances of Swift Extensions

Read Original

This article delves into three specific nuances of Swift extensions that often surprise developers: the visibility extensions have into the extended type's private members, how the extension's file location affects that visibility, and the default access modifiers for extension members. Through a practical example with a Person struct, the author demonstrates that extensions can access private properties when defined in the same file, but access control rules change across files. The article also clarifies common misunderstandings about Swift access control, making it valuable for iOS/macOS developers working with Swift.

3 Nuances of Swift Extensions

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser