Reputation: 387
Is there any keyboard shortcut for '// MARK:' in swift like there is for header doc '/// Description' ?
Upvotes: 16
Views: 9804
Reputation: 1
With SwiftUI, creating a code snippet changes by just selecting the MARK line // MARK: <#Description#>
and right click the selection, choosing "Create Code Snippet..."
It will open a prompt to create the snippet just like the accepted answer from @Ahmad F
The usage is the same, just type mark.
Upvotes: 0
Reputation: 272
There is one Command we have to use before any function or Methods or top of Coding line.
COMMAND + OPTION + /
If It is top of collectionView methods it will be like
// MARK: - CollectionView Methods
extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout {
/// Collection Views for Fetured, Popular, Categories
///
/// - Parameters:
/// - collectionView: Data to be provided by service. Collection Views are categoriesCollectionView, popularCollectionView, feturedCollectionView
/// - section: retturn Value from Service
/// - Returns: return Value from Service
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return homeList.count
}
Upvotes: 6
Reputation: 31655
There is no problem to add it as a code snippet to Xcode.
What you should do is:
// MARK: <#Description#>
, select it and then drag it to the code snippet in the utilities section:and that's it!
Usage:
As per the screenshot above, the completion handler shortcut is: 'm'; By typing 'm' in the code area, you should see:
Upvotes: 39
Reputation: 361
No there isn't any shortcuts for the //MARK. However, you can create a code snippet for it and re-use whenever and wherever you want.
Steps:
You would be asked to create a name for the snippet. Label it appropriately. And that's it.
For usage, Drag and drop this snippet anywhere you want
Upvotes: 6