《The Swift Programming Language》中文版
IBInspectable / IBDesignable
- How to make awesome UI components in iOS 8 using Swift and XCode 6
- Creating Your Own Custom Controls Using IBDesignable in Xcode 6
IBInspectable 可以在Attribute Inspector中公开类的属性。
IBDesignable 可以实时更新View。
Swift问题
What the meaning of question mark ‘?’ in swift?(swift中的?表示什么意思?)
You can use if and let together to work with values that might be missing. These values are represented as optionals. An optional value either contains a value or contains nil to indicate that the value is missing. Write a question mark (?) after the type of a value to mark the value as optional. If the optional value is nil,the conditional is false and the code in braces is skipped. Otherwise,the optional value is unwrapped and assigned to the constant after let,which makes the unwrapped value available inside the block of code.
What does an exclamation mark mean in the Swift language?(Swift中的!的意思?)
The exclamation mark effectively says,“I know that this optional definitely has a value; please use it.” This is known as forced unwrapping of the optional’s value:
Swift variable decorations with “?” (question mark) and “!” (exclamation mark)
Swift : Difference in ‘!’ and ‘?’ in swift
What is an Optional in Swift