Swift code Comment analysis Xcode hints for improved readability

Source: Internet
Author: User

Detailed Address: Http://www.code4app.com/forum.php?mod=viewthread&tid=9133#lastpost

When I saw my code yesterday, I found my comment was too messy, and I couldn't see it clearly.

Before using OC's time also used a simple comment, and then went to find a bit of information to see, Swift under a few comment key words have changed

is mainly

[Objective-c]View Source file copy code ?
123456789 `//``///` `//MARK: - ` `//TODO: -``//FIXME: - `



The first '//' is certainly the most familiar, simple line of comments, shortcut keys ' cmd+/' This is not a lot of introduction
The following is to introduce the "////" This can show the function function, in code hints can appear
Simple usage:

[Objective-c]View Source file copy code ?
1234   ///获得cell大小和contenview的大小func getPicCollectionCellSize() -> CGSize {   returnxxxxxx    }



So you'll get a hint when you call.
<ignore_js_op>
Continue to strengthen: with parameters and return values

[Objective-c]View Source file copy code ?
12345678 ///获得cell大小和contenview的大小    ///    ///  - parameter 参数1: 说明    ///  - parameter 参数2: 测试    ///  - returns: 返回size         func getPicCollectionCellSize(tmp : Int) -> CGSize {           return xxxxxx            }



So you're going to have to press the option key on the function tip.
<ignore_js_op>


Next

'//mark:-'

[Objective-c]View Source file copy code ?
12345 //mark:-handling Collcetionviewdatasource     func CollectionView (Collectionview:uicollectionview, numberofitemsinsection Section:int), int{ &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; print (Picurl?). Count) &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; return picurl!. Count &NBSP;&NBSP;&NBSP; }



<ignore_js_op>


'//todo:-' Simple introduction

<ignore_js_op>


'//fixme:-' Can prompt bug

<ignore_js_op>

Basically mastering these, your code is much more readable.

Swift code Comment analysis Xcode hints for improved readability

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.