The problem of unwrapped and wrapped variable value

Source: Internet
Author: User

The problem of unwrapped and wrapped variable value

When we define a tableview, we can use 3 definitions, the first of which is defined as optional (anyobject? form, the second form of non-optional (Anyobject and anyobject! )。

variables in the optional mode need to be unpacked when used, as follows:

Because objects in View.addsubview only support unpacking objects (func addsubview (view: UIView)), you need to unpack the object when you add a child view.

The non-optional- mode variable is used directly when using the object, as follows:

So we need to remove all the unpacking operations:

Summary:

Although these little grammatical features are not so much of a concern, the design requirements are not complete when designing complex class structures that are not very clear at the end of the branch.

The problem of unwrapped and wrapped variable value

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.