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 { return xxxxxx } |
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