In Swift?! Weak unowned's understanding.

Source: Internet
Author: User

? Equivalent to a layer of packets on the property, that is, a optional value, and optional has none and some two values, the property is not initialized when defined by the result is swift automatically initialized to nil value (that is, none in optional, essentially a value), When the property is nil during use, its value is. None to judge; we should judge if value {} Before using it in a rigorous manner; is relatively implicitly-style unpacking, the call process will be added by default! ;

So: In the controller we have determined that the added controls are initialized in Viewdidload and are not destroyed in the life cycle, so consider them! and relative to some of the properties of the constant string,cgfloat type, in the period may be empty, so use?

Role: in attributes? is to avoid crash for nil, and! Avoid repetitive judgments, efficient and concise

In Swift?! Weak unowned's understanding.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.